diff --git a/composer.json b/composer.json index 81055efd8..6878ea80f 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/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 186b8e34c..98341ee28 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -25,14 +25,22 @@ 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; +use Thelia\Form\CustomerModification; +use Thelia\Model\Customer as CustomerModel; +use Thelia\Log\Tlog; +use Thelia\Model\CustomerQuery; class Customer implements EventSubscriberInterface { public function create(ActionEvent $event) { + + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CREATECUSTOMER, $event); + $request = $event->getRequest(); $customerForm = new CustomerCreation($request); @@ -44,15 +52,78 @@ class Customer implements EventSubscriberInterface $form->bind($request); if ($form->isValid()) { - echo "ok"; exit; + $data = $form->getData(); + $customer = new CustomerModel(); + try { + \Thelia\Log\Tlog::getInstance()->debug($data); + $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"], + $request->getSession()->get("lang") + ); + } catch (\PropelException $e) { + Tlog::getInstance()->error(sprintf('error during creating customer on action/createCustomer with message "%s"', $e->getMessage())); + $event->setFormError($form); + } + + //Customer is create, he is automatically connected + } else { - echo "ko"; exit; + + $event->setFormError($form); } } + + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECUSTOMER, $event); } 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/Admin/Controller/BaseAdminController.php b/core/lib/Thelia/Admin/Controller/BaseAdminController.php index f63f87d21..1c193a966 100755 --- a/core/lib/Thelia/Admin/Controller/BaseAdminController.php +++ b/core/lib/Thelia/Admin/Controller/BaseAdminController.php @@ -48,7 +48,7 @@ class BaseAdminController extends ContainerAware */ public function render($templateName, $args = array()) { - $args = array_merge($args, array('lang' => 'fr')); // FIXME + $args = array_merge($args, array('lang' => 'fr')); $response = new Response(); @@ -57,7 +57,7 @@ class BaseAdminController extends ContainerAware public function renderRaw($templateName, $args = array()) { - $args = array_merge($args, array('lang' => 'fr')); // FIXME + $args = array_merge($args, array('lang' => 'fr')); return $this->getParser()->render($templateName, $args); } @@ -79,17 +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"); - } - - protected function isGranted() { - } } \ No newline at end of file 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/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index b163f1983..f4140d5a6 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -24,6 +24,8 @@
+ + 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/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 diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 3ffac068f..aca4e106a 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -47,4 +47,10 @@ final class TheliaEvents * Send before starting thelia inclusion */ const INCLUSION = "thelia.include"; + + const BEFORE_CREATECUSTOMER = "action.before_createcustomer"; + + const AFTER_CREATECUSTOMER = "action.after_createcustomer"; + + const CREATECUSTOMER_CUSTOMREF = "customer.creation.customref"; } 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/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 0ee3872de..8345ae06a 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; /** * @@ -81,7 +82,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); @@ -95,7 +96,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); @@ -111,7 +112,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 161727f51..44874ed59 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\Criteria; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; @@ -32,6 +33,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; @@ -109,7 +111,7 @@ class Category extends BaseLoop $search = CategoryQuery::create(); if (!is_null($this->id)) { - $search->filterById($this->id, \Criteria::IN); + $search->filterById($this->id, Criteria::IN); } if (!is_null($this->parent)) { @@ -119,11 +121,11 @@ class Category extends BaseLoop if ($this->current === true) { $search->filterById($this->request->get("category_id")); } elseif ($this->current === false) { - $search->filterById($this->request->get("category_id"), \Criteria::NOT_IN); + $search->filterById($this->request->get("category_id"), Criteria::NOT_IN); } if (!is_null($this->exclude)) { - $search->filterById($this->exclude, \Criteria::NOT_IN); + $search->filterById($this->exclude, Criteria::NOT_IN); } if (!is_null($this->link)) { @@ -157,7 +159,11 @@ 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); diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 51ff06e9c..2ff6be8e3 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -88,8 +88,17 @@ 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); + $this->request->getSession()->set("form_error", false); + } + + $template->assign("form", $form->createView()); } else { return $content; } @@ -202,7 +211,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/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index 72a72f4f9..6008939fb 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,6 +97,22 @@ 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); + + if ($this->isDebug()) { + $serviceContainer->setLogger('defaultLogger', Tlog::getInstance()); + + $con = Propel::getConnection("thelia"); + $con->useDebug(true); } } diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index c315662e0..f6df3a62b 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -22,6 +22,7 @@ /*************************************************************************************/ namespace Thelia\Core; +use Propel\Runtime\ActiveQuery\ModelCriteria; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; @@ -76,6 +77,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'); @@ -119,6 +121,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(), ModelCriteria::LIKE)->findOne(); + } + + //find default lang + return Model\LangQuery::create()->findOneByByDefault(1); + + } } diff --git a/core/lib/Thelia/Form/AdminLogin.php b/core/lib/Thelia/Form/AdminLogin.php index 32a8e0255..71e18d3c3 100644 --- a/core/lib/Thelia/Form/AdminLogin.php +++ b/core/lib/Thelia/Form/AdminLogin.php @@ -47,4 +47,9 @@ class AdminLogin extends BaseForm { ->add("remember_me", "checkbox"); } + 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 02f86fe02..b53747a5d 100644 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -38,25 +38,33 @@ 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__)) ) ) ) ->addExtension(new ValidatorExtension($validator)) ->getFormFactory() - ->createBuilder($type, $data, $options); + ->createNamedBuilder($this->getName(), $type, $data, $options); ; + + $this->buildForm(); } @@ -68,7 +76,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 \Symfony\Component\Validator\Constraints\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(); } diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index 68726356d..b151fc98d 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -24,7 +24,11 @@ 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 Symfony\Component\Validator\ExecutionContext; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Model\ConfigQuery; +use Thelia\Model\CustomerQuery; class CustomerCreation extends BaseForm @@ -32,17 +36,133 @@ class CustomerCreation extends BaseForm protected function buildForm() { - $this->form->add("name", "text") + $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" + )) ->add("email", "email", array( - "attr" => array( - "class" => "field" - ), - "label" => "email", - "constraints" => array( - new NotBlank() - ) - ) - ) - ->add('age', 'integer'); + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Email(), + new Constraints\Callback(array( + "methods" => array( + array($this, + "verifyExistingEmail") + ) + )) + ), + "label" => "email" + )) + ->add("email_confirm", "email", array( + "constraints" => array( + new Constraints\Callback(array( + "methods" => array( + array($this, + "verifyEmailField") + ) + )) + ), + "label" => "email confirmation" + )) + ->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") + ))) + ), + "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"; } } \ No newline at end of file diff --git a/core/lib/Thelia/Form/CustomerModification.php b/core/lib/Thelia/Form/CustomerModification.php new file mode 100644 index 000000000..cb21be2fa --- /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 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 @@ -getLogin(); - } - - /** - * {@inheritDoc} - */ - public function eraseCredentials() { - $this->setPassword(null); - } - - /** - * {@inheritDoc} - */ - public function getRoles() { - return array(new Role('USER_CUSTOMER')); - } +class Admin extends BaseAdmin { } diff --git a/core/lib/Thelia/Model/AdminGroup.php b/core/lib/Thelia/Model/AdminGroup.php old mode 100755 new mode 100644 index c412763bb..4f84ca894 --- a/core/lib/Thelia/Model/AdminGroup.php +++ b/core/lib/Thelia/Model/AdminGroup.php @@ -2,20 +2,8 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseAdminGroup; +use Thelia\Model\Base\AdminGroup as BaseAdminGroup; +class AdminGroup extends BaseAdminGroup { -/** - * Skeleton subclass for representing a row from the 'admin_group' 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 AdminGroup extends BaseAdminGroup -{ } diff --git a/core/lib/Thelia/Model/AdminGroupPeer.php b/core/lib/Thelia/Model/AdminGroupPeer.php deleted file mode 100755 index 15f1e964d..000000000 --- a/core/lib/Thelia/Model/AdminGroupPeer.php +++ /dev/null @@ -1,21 +0,0 @@ -modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Accessory instance. If + * obj is an instance of Accessory, delegates to + * equals(Accessory). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Accessory The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Accessory The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\Accessory The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AccessoryTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\Accessory The current object (for fluent API support) + */ + public function setProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->product_id !== $v) { + $this->product_id = $v; + $this->modifiedColumns[] = AccessoryTableMap::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 \Thelia\Model\Accessory The current object (for fluent API support) + */ + public function setAccessory($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->accessory !== $v) { + $this->accessory = $v; + $this->modifiedColumns[] = AccessoryTableMap::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 \Thelia\Model\Accessory The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = AccessoryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AccessoryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AccessoryTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AccessoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AccessoryTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AccessoryTableMap::translateFieldName('Accessory', TableMap::TYPE_PHPNAME, $indexType)]; + $this->accessory = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AccessoryTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AccessoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AccessoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = AccessoryTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\Accessory object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(AccessoryTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildAccessoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see Accessory::setDeleted() + * @see Accessory::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildAccessoryQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AccessoryTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AccessoryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AccessoryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + AccessoryTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AccessoryTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(AccessoryTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; + } + if ($this->isColumnModified(AccessoryTableMap::ACCESSORY)) { + $modifiedColumns[':p' . $index++] = 'ACCESSORY'; + } + if ($this->isColumnModified(AccessoryTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(AccessoryTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(AccessoryTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = AccessoryTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()] = true; + $keys = AccessoryTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = AccessoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = AccessoryTableMap::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(AccessoryTableMap::DATABASE_NAME); + + if ($this->isColumnModified(AccessoryTableMap::ID)) $criteria->add(AccessoryTableMap::ID, $this->id); + if ($this->isColumnModified(AccessoryTableMap::PRODUCT_ID)) $criteria->add(AccessoryTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(AccessoryTableMap::ACCESSORY)) $criteria->add(AccessoryTableMap::ACCESSORY, $this->accessory); + if ($this->isColumnModified(AccessoryTableMap::POSITION)) $criteria->add(AccessoryTableMap::POSITION, $this->position); + if ($this->isColumnModified(AccessoryTableMap::CREATED_AT)) $criteria->add(AccessoryTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AccessoryTableMap::UPDATED_AT)) $criteria->add(AccessoryTableMap::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(AccessoryTableMap::DATABASE_NAME); + $criteria->add(AccessoryTableMap::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 \Thelia\Model\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->setId($this->getId()); + $copyObj->setProductId($this->getProductId()); + $copyObj->setAccessory($this->getAccessory()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + 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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildProduct object. + * + * @param ChildProduct $v + * @return \Thelia\Model\Accessory The current object (for fluent API support) + * @throws PropelException + */ + public function setProductRelatedByProductId(ChildProduct $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 ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addAccessoryRelatedByProductId($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProductRelatedByProductId(ConnectionInterface $con = null) + { + if ($this->aProductRelatedByProductId === null && ($this->product_id !== null)) { + $this->aProductRelatedByProductId = ChildProductQuery::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->addAccessoriesRelatedByProductId($this); + */ + } + + return $this->aProductRelatedByProductId; + } + + /** + * Declares an association between this object and a ChildProduct object. + * + * @param ChildProduct $v + * @return \Thelia\Model\Accessory The current object (for fluent API support) + * @throws PropelException + */ + public function setProductRelatedByAccessory(ChildProduct $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 ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addAccessoryRelatedByAccessory($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProductRelatedByAccessory(ConnectionInterface $con = null) + { + if ($this->aProductRelatedByAccessory === null && ($this->accessory !== null)) { + $this->aProductRelatedByAccessory = ChildProductQuery::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->addAccessoriesRelatedByAccessory($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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProductRelatedByProductId = null; + $this->aProductRelatedByAccessory = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AccessoryTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildAccessory The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AccessoryTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php b/core/lib/Thelia/Model/Base/AccessoryQuery.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseAccessoryQuery.php rename to core/lib/Thelia/Model/Base/AccessoryQuery.php index 3f60bf748..82bb03a70 --- a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php +++ b/core/lib/Thelia/Model/Base/AccessoryQuery.php @@ -1,99 +1,99 @@ setModelAlias($modelAlias); } @@ -114,21 +114,21 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Accessory|Accessory[]|mixed the result, formatted by the current formatter + * @return ChildAccessory|array|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 + if ((null !== ($obj = AccessoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AccessoryTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -140,46 +140,31 @@ abstract class BaseAccessoryQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Accessory A model object, or null if the key is not found - * @throws PropelException + * @return ChildAccessory A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `product_id`, `accessory`, `position`, `created_at`, `updated_at` FROM `accessory` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Accessory(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAccessory(); $obj->hydrate($row); - AccessoryPeer::addInstanceToPool($obj, (string) $key); + AccessoryTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -190,19 +175,19 @@ abstract class BaseAccessoryQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Accessory|Accessory[]|mixed the result, formatted by the current formatter + * @return ChildAccessory|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -211,22 +196,22 @@ abstract class BaseAccessoryQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Accessory[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -234,12 +219,12 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AccessoryQuery The current query, for fluid interface + * @return ChildAccessoryQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(AccessoryPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AccessoryTableMap::ID, $key, Criteria::EQUAL); } /** @@ -247,12 +232,12 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AccessoryQuery The current query, for fluid interface + * @return ChildAccessoryQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(AccessoryPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AccessoryTableMap::ID, $keys, Criteria::IN); } /** @@ -262,8 +247,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -272,18 +256,18 @@ abstract class BaseAccessoryQuery extends ModelCriteria * 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 + * @return ChildAccessoryQuery 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); + $this->addUsingAlias(AccessoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AccessoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AccessoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -294,7 +278,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AccessoryPeer::ID, $id, $comparison); + return $this->addUsingAlias(AccessoryTableMap::ID, $id, $comparison); } /** @@ -304,8 +288,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * $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 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 * * * @see filterByProductRelatedByProductId() @@ -316,18 +299,18 @@ abstract class BaseAccessoryQuery extends ModelCriteria * 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 + * @return ChildAccessoryQuery 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); + $this->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($productId['max'])) { - $this->addUsingAlias(AccessoryPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -338,7 +321,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AccessoryPeer::PRODUCT_ID, $productId, $comparison); + return $this->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $productId, $comparison); } /** @@ -348,8 +331,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * $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 + * $query->filterByAccessory(array('min' => 12)); // WHERE accessory > 12 * * * @see filterByProductRelatedByAccessory() @@ -360,18 +342,18 @@ abstract class BaseAccessoryQuery extends ModelCriteria * 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 + * @return ChildAccessoryQuery 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); + $this->addUsingAlias(AccessoryTableMap::ACCESSORY, $accessory['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($accessory['max'])) { - $this->addUsingAlias(AccessoryPeer::ACCESSORY, $accessory['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AccessoryTableMap::ACCESSORY, $accessory['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -382,7 +364,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AccessoryPeer::ACCESSORY, $accessory, $comparison); + return $this->addUsingAlias(AccessoryTableMap::ACCESSORY, $accessory, $comparison); } /** @@ -392,8 +374,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -402,18 +383,18 @@ abstract class BaseAccessoryQuery extends ModelCriteria * 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 + * @return ChildAccessoryQuery 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); + $this->addUsingAlias(AccessoryTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(AccessoryPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AccessoryTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -424,7 +405,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AccessoryPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(AccessoryTableMap::POSITION, $position, $comparison); } /** @@ -445,18 +426,18 @@ abstract class BaseAccessoryQuery extends ModelCriteria * 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 + * @return ChildAccessoryQuery 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); + $this->addUsingAlias(AccessoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AccessoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AccessoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -467,7 +448,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AccessoryPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AccessoryTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -488,18 +469,18 @@ abstract class BaseAccessoryQuery extends ModelCriteria * 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 + * @return ChildAccessoryQuery 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); + $this->addUsingAlias(AccessoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AccessoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AccessoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -510,32 +491,31 @@ abstract class BaseAccessoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AccessoryPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AccessoryTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildAccessoryQuery The current query, for fluid interface */ public function filterByProductRelatedByProductId($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(AccessoryPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AccessoryPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AccessoryTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProductRelatedByProductId() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProductRelatedByProductId() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -545,7 +525,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria * @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 + * @return ChildAccessoryQuery The current query, for fluid interface */ public function joinProductRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -574,7 +554,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria /** * Use the ProductRelatedByProductId relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -590,28 +570,27 @@ abstract class BaseAccessoryQuery extends ModelCriteria } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildAccessoryQuery The current query, for fluid interface */ public function filterByProductRelatedByAccessory($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(AccessoryPeer::ACCESSORY, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(AccessoryTableMap::ACCESSORY, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AccessoryPeer::ACCESSORY, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AccessoryTableMap::ACCESSORY, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProductRelatedByAccessory() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProductRelatedByAccessory() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -621,7 +600,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria * @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 + * @return ChildAccessoryQuery The current query, for fluid interface */ public function joinProductRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -650,7 +629,7 @@ abstract class BaseAccessoryQuery extends ModelCriteria /** * Use the ProductRelatedByAccessory relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -668,19 +647,94 @@ abstract class BaseAccessoryQuery extends ModelCriteria /** * Exclude object from result * - * @param Accessory $accessory Object to remove from the list of results + * @param ChildAccessory $accessory Object to remove from the list of results * - * @return AccessoryQuery The current query, for fluid interface + * @return ChildAccessoryQuery The current query, for fluid interface */ public function prune($accessory = null) { if ($accessory) { - $this->addUsingAlias(AccessoryPeer::ID, $accessory->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(AccessoryTableMap::ID, $accessory->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the accessory table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AccessoryTableMap::clearInstancePool(); + AccessoryTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAccessory or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAccessory object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AccessoryTableMap::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(); + + + AccessoryTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AccessoryTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -688,31 +742,11 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AccessoryQuery The current query, for fluid interface + * @return ChildAccessoryQuery 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); + return $this->addUsingAlias(AccessoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -720,30 +754,51 @@ abstract class BaseAccessoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AccessoryQuery The current query, for fluid interface + * @return ChildAccessoryQuery 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); + return $this->addUsingAlias(AccessoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAccessoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AccessoryTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAccessoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AccessoryTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AccessoryQuery The current query, for fluid interface + * @return ChildAccessoryQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AccessoryPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AccessoryTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AccessoryQuery The current query, for fluid interface + * @return ChildAccessoryQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AccessoryPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AccessoryTableMap::CREATED_AT); } -} + +} // AccessoryQuery diff --git a/core/lib/Thelia/Model/om/BaseAddress.php b/core/lib/Thelia/Model/Base/Address.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseAddress.php rename to core/lib/Thelia/Model/Base/Address.php index 62db82dbe..fe734960b --- a/core/lib/Thelia/Model/om/BaseAddress.php +++ b/core/lib/Thelia/Model/Base/Address.php @@ -1,53 +1,62 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Address instance. If + * obj is an instance of Address, delegates to + * equals(Address). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Address The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Address The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { + return $this->title; } /** * Get the [customer_id] column value. * - * @return int + * @return int */ public function getCustomerId() { + return $this->customer_id; } /** * Get the [customer_title_id] column value. * - * @return int + * @return int */ public function getCustomerTitleId() { + return $this->customer_title_id; } /** * Get the [company] column value. * - * @return string + * @return string */ public function getCompany() { + return $this->company; } /** * Get the [firstname] column value. * - * @return string + * @return string */ public function getFirstname() { + return $this->firstname; } /** * Get the [lastname] column value. * - * @return string + * @return string */ public function getLastname() { + return $this->lastname; } /** * Get the [address1] column value. * - * @return string + * @return string */ public function getAddress1() { + return $this->address1; } /** * Get the [address2] column value. * - * @return string + * @return string */ public function getAddress2() { + return $this->address2; } /** * Get the [address3] column value. * - * @return string + * @return string */ public function getAddress3() { + return $this->address3; } /** * Get the [zipcode] column value. * - * @return string + * @return string */ public function getZipcode() { + return $this->zipcode; } /** * Get the [city] column value. * - * @return string + * @return string */ public function getCity() { + return $this->city; } /** * Get the [country_id] column value. * - * @return int + * @return int */ public function getCountryId() { + return $this->country_id; } /** * Get the [phone] column value. * - * @return string + * @return string */ public function getPhone() { + return $this->phone; } @@ -319,97 +584,57 @@ abstract class BaseAddress extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = AddressPeer::ID; + $this->modifiedColumns[] = AddressTableMap::ID; } @@ -419,18 +644,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setTitle($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->title !== $v) { $this->title = $v; - $this->modifiedColumns[] = AddressPeer::TITLE; + $this->modifiedColumns[] = AddressTableMap::TITLE; } @@ -440,18 +665,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [customer_id] column. * - * @param int $v new value - * @return Address The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setCustomerId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->customer_id !== $v) { $this->customer_id = $v; - $this->modifiedColumns[] = AddressPeer::CUSTOMER_ID; + $this->modifiedColumns[] = AddressTableMap::CUSTOMER_ID; } if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) { @@ -465,18 +690,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [customer_title_id] column. * - * @param int $v new value - * @return Address The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setCustomerTitleId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->customer_title_id !== $v) { $this->customer_title_id = $v; - $this->modifiedColumns[] = AddressPeer::CUSTOMER_TITLE_ID; + $this->modifiedColumns[] = AddressTableMap::CUSTOMER_TITLE_ID; } if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) { @@ -490,18 +715,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [company] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setCompany($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->company !== $v) { $this->company = $v; - $this->modifiedColumns[] = AddressPeer::COMPANY; + $this->modifiedColumns[] = AddressTableMap::COMPANY; } @@ -511,18 +736,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [firstname] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setFirstname($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->firstname !== $v) { $this->firstname = $v; - $this->modifiedColumns[] = AddressPeer::FIRSTNAME; + $this->modifiedColumns[] = AddressTableMap::FIRSTNAME; } @@ -532,18 +757,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [lastname] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setLastname($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->lastname !== $v) { $this->lastname = $v; - $this->modifiedColumns[] = AddressPeer::LASTNAME; + $this->modifiedColumns[] = AddressTableMap::LASTNAME; } @@ -553,18 +778,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [address1] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setAddress1($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->address1 !== $v) { $this->address1 = $v; - $this->modifiedColumns[] = AddressPeer::ADDRESS1; + $this->modifiedColumns[] = AddressTableMap::ADDRESS1; } @@ -574,18 +799,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [address2] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setAddress2($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->address2 !== $v) { $this->address2 = $v; - $this->modifiedColumns[] = AddressPeer::ADDRESS2; + $this->modifiedColumns[] = AddressTableMap::ADDRESS2; } @@ -595,18 +820,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [address3] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setAddress3($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->address3 !== $v) { $this->address3 = $v; - $this->modifiedColumns[] = AddressPeer::ADDRESS3; + $this->modifiedColumns[] = AddressTableMap::ADDRESS3; } @@ -616,18 +841,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [zipcode] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setZipcode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->zipcode !== $v) { $this->zipcode = $v; - $this->modifiedColumns[] = AddressPeer::ZIPCODE; + $this->modifiedColumns[] = AddressTableMap::ZIPCODE; } @@ -637,18 +862,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [city] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setCity($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->city !== $v) { $this->city = $v; - $this->modifiedColumns[] = AddressPeer::CITY; + $this->modifiedColumns[] = AddressTableMap::CITY; } @@ -658,18 +883,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [country_id] column. * - * @param int $v new value - * @return Address The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setCountryId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->country_id !== $v) { $this->country_id = $v; - $this->modifiedColumns[] = AddressPeer::COUNTRY_ID; + $this->modifiedColumns[] = AddressTableMap::COUNTRY_ID; } @@ -679,18 +904,18 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Set the value of [phone] column. * - * @param string $v new value - * @return Address The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setPhone($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->phone !== $v) { $this->phone = $v; - $this->modifiedColumns[] = AddressPeer::PHONE; + $this->modifiedColumns[] = AddressTableMap::PHONE; } @@ -700,19 +925,17 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AddressTableMap::CREATED_AT; } } // if either are not null @@ -723,19 +946,17 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Address The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AddressTableMap::UPDATED_AT; } } // if either are not null @@ -753,7 +974,7 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -765,32 +986,74 @@ abstract class BaseAddress extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AddressTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AddressTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AddressTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->customer_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AddressTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->customer_title_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AddressTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)]; + $this->company = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AddressTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->firstname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AddressTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lastname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AddressTableMap::translateFieldName('Address1', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address1 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AddressTableMap::translateFieldName('Address2', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address2 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : AddressTableMap::translateFieldName('Address3', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address3 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : AddressTableMap::translateFieldName('Zipcode', TableMap::TYPE_PHPNAME, $indexType)]; + $this->zipcode = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : AddressTableMap::translateFieldName('City', TableMap::TYPE_PHPNAME, $indexType)]; + $this->city = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : AddressTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->country_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : AddressTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)]; + $this->phone = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : AddressTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : AddressTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -798,11 +1061,11 @@ abstract class BaseAddress extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 16; // 16 = AddressPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 16; // 16 = AddressTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Address object", $e); + throw new PropelException("Error populating \Thelia\Model\Address object", 0, $e); } } @@ -821,7 +1084,6 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) { $this->aCustomer = null; } @@ -835,12 +1097,12 @@ abstract class BaseAddress extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -851,19 +1113,19 @@ abstract class BaseAddress extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AddressTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildAddressQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -875,26 +1137,25 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Address::setDeleted() + * @see Address::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = AddressQuery::create() + $deleteQuery = ChildAddressQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -919,20 +1180,19 @@ abstract class BaseAddress extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -942,16 +1202,16 @@ abstract class BaseAddress extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(AddressPeer::CREATED_AT)) { + if (!$this->isColumnModified(AddressTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(AddressPeer::UPDATED_AT)) { + if (!$this->isColumnModified(AddressTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AddressPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(AddressTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -963,7 +1223,7 @@ abstract class BaseAddress extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - AddressPeer::addInstanceToPool($this); + AddressTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -982,19 +1242,19 @@ abstract class BaseAddress extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -1033,73 +1293,73 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = AddressPeer::ID; + $this->modifiedColumns[] = AddressTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AddressPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AddressTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AddressPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(AddressTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(AddressPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; + if ($this->isColumnModified(AddressTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; } - if ($this->isColumnModified(AddressPeer::CUSTOMER_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_id`'; + if ($this->isColumnModified(AddressTableMap::CUSTOMER_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID'; } - if ($this->isColumnModified(AddressPeer::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_title_id`'; + if ($this->isColumnModified(AddressTableMap::CUSTOMER_TITLE_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID'; } - if ($this->isColumnModified(AddressPeer::COMPANY)) { - $modifiedColumns[':p' . $index++] = '`company`'; + if ($this->isColumnModified(AddressTableMap::COMPANY)) { + $modifiedColumns[':p' . $index++] = 'COMPANY'; } - if ($this->isColumnModified(AddressPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`firstname`'; + if ($this->isColumnModified(AddressTableMap::FIRSTNAME)) { + $modifiedColumns[':p' . $index++] = 'FIRSTNAME'; } - if ($this->isColumnModified(AddressPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`lastname`'; + if ($this->isColumnModified(AddressTableMap::LASTNAME)) { + $modifiedColumns[':p' . $index++] = 'LASTNAME'; } - if ($this->isColumnModified(AddressPeer::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = '`address1`'; + if ($this->isColumnModified(AddressTableMap::ADDRESS1)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS1'; } - if ($this->isColumnModified(AddressPeer::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = '`address2`'; + if ($this->isColumnModified(AddressTableMap::ADDRESS2)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS2'; } - if ($this->isColumnModified(AddressPeer::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = '`address3`'; + if ($this->isColumnModified(AddressTableMap::ADDRESS3)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS3'; } - if ($this->isColumnModified(AddressPeer::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = '`zipcode`'; + if ($this->isColumnModified(AddressTableMap::ZIPCODE)) { + $modifiedColumns[':p' . $index++] = 'ZIPCODE'; } - if ($this->isColumnModified(AddressPeer::CITY)) { - $modifiedColumns[':p' . $index++] = '`city`'; + if ($this->isColumnModified(AddressTableMap::CITY)) { + $modifiedColumns[':p' . $index++] = 'CITY'; } - if ($this->isColumnModified(AddressPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`country_id`'; + if ($this->isColumnModified(AddressTableMap::COUNTRY_ID)) { + $modifiedColumns[':p' . $index++] = 'COUNTRY_ID'; } - if ($this->isColumnModified(AddressPeer::PHONE)) { - $modifiedColumns[':p' . $index++] = '`phone`'; + if ($this->isColumnModified(AddressTableMap::PHONE)) { + $modifiedColumns[':p' . $index++] = 'PHONE'; } - if ($this->isColumnModified(AddressPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(AddressTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(AddressPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(AddressTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `address` (%s) VALUES (%s)', + 'INSERT INTO address (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1108,66 +1368,66 @@ abstract class BaseAddress extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`title`': + case 'TITLE': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`customer_id`': + case 'CUSTOMER_ID': $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); break; - case '`customer_title_id`': + case 'CUSTOMER_TITLE_ID': $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); break; - case '`company`': + case 'COMPANY': $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); break; - case '`firstname`': + case 'FIRSTNAME': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; - case '`lastname`': + case 'LASTNAME': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; - case '`address1`': + case 'ADDRESS1': $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); break; - case '`address2`': + case 'ADDRESS2': $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); break; - case '`address3`': + case 'ADDRESS3': $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); break; - case '`zipcode`': + case 'ZIPCODE': $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); break; - case '`city`': + case 'CITY': $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); break; - case '`country_id`': + case 'COUNTRY_ID': $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); break; - case '`phone`': + case 'PHONE': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -1177,122 +1437,32 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = AddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = AddressTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1302,7 +1472,7 @@ abstract class BaseAddress extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1368,22 +1538,22 @@ abstract class BaseAddress extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = AddressTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getTitle(), @@ -1402,6 +1572,12 @@ abstract class BaseAddress extends BaseObject implements Persistent $keys[14] => $this->getCreatedAt(), $keys[15] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aCustomer) { $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -1417,27 +1593,27 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = AddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = AddressTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1503,17 +1679,17 @@ abstract class BaseAddress extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = AddressPeer::getFieldNames($keyType); + $keys = AddressTableMap::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]]); @@ -1540,24 +1716,24 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(AddressPeer::DATABASE_NAME); + $criteria = new Criteria(AddressTableMap::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); + if ($this->isColumnModified(AddressTableMap::ID)) $criteria->add(AddressTableMap::ID, $this->id); + if ($this->isColumnModified(AddressTableMap::TITLE)) $criteria->add(AddressTableMap::TITLE, $this->title); + if ($this->isColumnModified(AddressTableMap::CUSTOMER_ID)) $criteria->add(AddressTableMap::CUSTOMER_ID, $this->customer_id); + if ($this->isColumnModified(AddressTableMap::CUSTOMER_TITLE_ID)) $criteria->add(AddressTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id); + if ($this->isColumnModified(AddressTableMap::COMPANY)) $criteria->add(AddressTableMap::COMPANY, $this->company); + if ($this->isColumnModified(AddressTableMap::FIRSTNAME)) $criteria->add(AddressTableMap::FIRSTNAME, $this->firstname); + if ($this->isColumnModified(AddressTableMap::LASTNAME)) $criteria->add(AddressTableMap::LASTNAME, $this->lastname); + if ($this->isColumnModified(AddressTableMap::ADDRESS1)) $criteria->add(AddressTableMap::ADDRESS1, $this->address1); + if ($this->isColumnModified(AddressTableMap::ADDRESS2)) $criteria->add(AddressTableMap::ADDRESS2, $this->address2); + if ($this->isColumnModified(AddressTableMap::ADDRESS3)) $criteria->add(AddressTableMap::ADDRESS3, $this->address3); + if ($this->isColumnModified(AddressTableMap::ZIPCODE)) $criteria->add(AddressTableMap::ZIPCODE, $this->zipcode); + if ($this->isColumnModified(AddressTableMap::CITY)) $criteria->add(AddressTableMap::CITY, $this->city); + if ($this->isColumnModified(AddressTableMap::COUNTRY_ID)) $criteria->add(AddressTableMap::COUNTRY_ID, $this->country_id); + if ($this->isColumnModified(AddressTableMap::PHONE)) $criteria->add(AddressTableMap::PHONE, $this->phone); + if ($this->isColumnModified(AddressTableMap::CREATED_AT)) $criteria->add(AddressTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AddressTableMap::UPDATED_AT)) $criteria->add(AddressTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1572,15 +1748,15 @@ abstract class BaseAddress extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(AddressPeer::DATABASE_NAME); - $criteria->add(AddressPeer::ID, $this->id); + $criteria = new Criteria(AddressTableMap::DATABASE_NAME); + $criteria->add(AddressTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1590,7 +1766,7 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1614,9 +1790,9 @@ abstract class BaseAddress extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1636,18 +1812,6 @@ abstract class BaseAddress extends BaseObject implements Persistent $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 @@ -1662,8 +1826,8 @@ abstract class BaseAddress extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Address Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1677,31 +1841,13 @@ abstract class BaseAddress extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildCustomer object. * - * 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) + * @param ChildCustomer $v + * @return \Thelia\Model\Address The current object (for fluent API support) * @throws PropelException */ - public function setCustomer(Customer $v = null) + public function setCustomer(ChildCustomer $v = null) { if ($v === null) { $this->setCustomerId(NULL); @@ -1712,7 +1858,7 @@ abstract class BaseAddress extends BaseObject implements Persistent $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 this object has already been added to the ChildCustomer object, it will not be re-added. if ($v !== null) { $v->addAddress($this); } @@ -1723,23 +1869,22 @@ abstract class BaseAddress extends BaseObject implements Persistent /** - * Get the associated Customer object + * Get the associated ChildCustomer object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Customer The associated Customer object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCustomer The associated ChildCustomer object. * @throws PropelException */ - public function getCustomer(PropelPDO $con = null, $doQuery = true) + public function getCustomer(ConnectionInterface $con = null) { - if ($this->aCustomer === null && ($this->customer_id !== null) && $doQuery) { - $this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con); + if ($this->aCustomer === null && ($this->customer_id !== null)) { + $this->aCustomer = ChildCustomerQuery::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); + $this->aCustomer->addAddresses($this); */ } @@ -1747,13 +1892,13 @@ abstract class BaseAddress extends BaseObject implements Persistent } /** - * Declares an association between this object and a CustomerTitle object. + * Declares an association between this object and a ChildCustomerTitle object. * - * @param CustomerTitle $v - * @return Address The current object (for fluent API support) + * @param ChildCustomerTitle $v + * @return \Thelia\Model\Address The current object (for fluent API support) * @throws PropelException */ - public function setCustomerTitle(CustomerTitle $v = null) + public function setCustomerTitle(ChildCustomerTitle $v = null) { if ($v === null) { $this->setCustomerTitleId(NULL); @@ -1764,7 +1909,7 @@ abstract class BaseAddress extends BaseObject implements Persistent $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 this object has already been added to the ChildCustomerTitle object, it will not be re-added. if ($v !== null) { $v->addAddress($this); } @@ -1775,23 +1920,22 @@ abstract class BaseAddress extends BaseObject implements Persistent /** - * Get the associated CustomerTitle object + * Get the associated ChildCustomerTitle object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return CustomerTitle The associated CustomerTitle object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCustomerTitle The associated ChildCustomerTitle object. * @throws PropelException */ - public function getCustomerTitle(PropelPDO $con = null, $doQuery = true) + public function getCustomerTitle(ConnectionInterface $con = null) { - if ($this->aCustomerTitle === null && ($this->customer_title_id !== null) && $doQuery) { - $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_id, $con); + if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) { + $this->aCustomerTitle = ChildCustomerTitleQuery::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); + $this->aCustomerTitle->addAddresses($this); */ } @@ -1820,8 +1964,6 @@ abstract class BaseAddress extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1833,22 +1975,13 @@ abstract class BaseAddress extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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) { } // if ($deep) $this->aCustomer = null; @@ -1856,23 +1989,13 @@ abstract class BaseAddress extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(AddressTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1880,13 +2003,131 @@ abstract class BaseAddress extends BaseObject implements Persistent /** * 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) + * @return ChildAddress The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = AddressPeer::UPDATED_AT; + $this->modifiedColumns[] = AddressTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseAddressQuery.php b/core/lib/Thelia/Model/Base/AddressQuery.php old mode 100755 new mode 100644 similarity index 56% rename from core/lib/Thelia/Model/om/BaseAddressQuery.php rename to core/lib/Thelia/Model/Base/AddressQuery.php index 46b6e5146..8611f14a8 --- a/core/lib/Thelia/Model/om/BaseAddressQuery.php +++ b/core/lib/Thelia/Model/Base/AddressQuery.php @@ -1,140 +1,139 @@ setModelAlias($modelAlias); } @@ -155,21 +154,21 @@ abstract class BaseAddressQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Address|Address[]|mixed the result, formatted by the current formatter + * @return ChildAddress|array|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 + if ((null !== ($obj = AddressTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AddressTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -181,46 +180,31 @@ abstract class BaseAddressQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Address A model object, or null if the key is not found - * @throws PropelException + * @return ChildAddress A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Address(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAddress(); $obj->hydrate($row); - AddressPeer::addInstanceToPool($obj, (string) $key); + AddressTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -231,19 +215,19 @@ abstract class BaseAddressQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Address|Address[]|mixed the result, formatted by the current formatter + * @return ChildAddress|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -252,22 +236,22 @@ abstract class BaseAddressQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Address[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -275,12 +259,12 @@ abstract class BaseAddressQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AddressQuery The current query, for fluid interface + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(AddressPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AddressTableMap::ID, $key, Criteria::EQUAL); } /** @@ -288,12 +272,12 @@ abstract class BaseAddressQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AddressQuery The current query, for fluid interface + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(AddressPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AddressTableMap::ID, $keys, Criteria::IN); } /** @@ -303,8 +287,7 @@ abstract class BaseAddressQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -313,18 +296,18 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery 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); + $this->addUsingAlias(AddressTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AddressPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AddressTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -335,7 +318,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::ID, $id, $comparison); + return $this->addUsingAlias(AddressTableMap::ID, $id, $comparison); } /** @@ -351,7 +334,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -364,7 +347,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(AddressTableMap::TITLE, $title, $comparison); } /** @@ -374,8 +357,7 @@ abstract class BaseAddressQuery extends ModelCriteria * * $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 + * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12 * * * @see filterByCustomer() @@ -386,18 +368,18 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery 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); + $this->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($customerId['max'])) { - $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -408,7 +390,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId, $comparison); + return $this->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customerId, $comparison); } /** @@ -418,8 +400,7 @@ abstract class BaseAddressQuery extends ModelCriteria * * $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 + * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12 * * * @see filterByCustomerTitle() @@ -430,18 +411,18 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery 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); + $this->addUsingAlias(AddressTableMap::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); + $this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -452,7 +433,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); + return $this->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); } /** @@ -468,7 +449,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByCompany($company = null, $comparison = null) { @@ -481,7 +462,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::COMPANY, $company, $comparison); + return $this->addUsingAlias(AddressTableMap::COMPANY, $company, $comparison); } /** @@ -497,7 +478,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByFirstname($firstname = null, $comparison = null) { @@ -510,7 +491,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::FIRSTNAME, $firstname, $comparison); + return $this->addUsingAlias(AddressTableMap::FIRSTNAME, $firstname, $comparison); } /** @@ -526,7 +507,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByLastname($lastname = null, $comparison = null) { @@ -539,7 +520,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::LASTNAME, $lastname, $comparison); + return $this->addUsingAlias(AddressTableMap::LASTNAME, $lastname, $comparison); } /** @@ -555,7 +536,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByAddress1($address1 = null, $comparison = null) { @@ -568,7 +549,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::ADDRESS1, $address1, $comparison); + return $this->addUsingAlias(AddressTableMap::ADDRESS1, $address1, $comparison); } /** @@ -584,7 +565,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByAddress2($address2 = null, $comparison = null) { @@ -597,7 +578,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::ADDRESS2, $address2, $comparison); + return $this->addUsingAlias(AddressTableMap::ADDRESS2, $address2, $comparison); } /** @@ -613,7 +594,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByAddress3($address3 = null, $comparison = null) { @@ -626,7 +607,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::ADDRESS3, $address3, $comparison); + return $this->addUsingAlias(AddressTableMap::ADDRESS3, $address3, $comparison); } /** @@ -642,7 +623,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByZipcode($zipcode = null, $comparison = null) { @@ -655,7 +636,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::ZIPCODE, $zipcode, $comparison); + return $this->addUsingAlias(AddressTableMap::ZIPCODE, $zipcode, $comparison); } /** @@ -671,7 +652,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByCity($city = null, $comparison = null) { @@ -684,7 +665,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::CITY, $city, $comparison); + return $this->addUsingAlias(AddressTableMap::CITY, $city, $comparison); } /** @@ -694,8 +675,7 @@ abstract class BaseAddressQuery extends ModelCriteria * * $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 + * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 * * * @param mixed $countryId The value to use as filter. @@ -704,18 +684,18 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery 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); + $this->addUsingAlias(AddressTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($countryId['max'])) { - $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AddressTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -726,7 +706,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId, $comparison); + return $this->addUsingAlias(AddressTableMap::COUNTRY_ID, $countryId, $comparison); } /** @@ -742,7 +722,7 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByPhone($phone = null, $comparison = null) { @@ -755,7 +735,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::PHONE, $phone, $comparison); + return $this->addUsingAlias(AddressTableMap::PHONE, $phone, $comparison); } /** @@ -776,18 +756,18 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery 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); + $this->addUsingAlias(AddressTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AddressTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -798,7 +778,7 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AddressTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -819,18 +799,18 @@ abstract class BaseAddressQuery extends ModelCriteria * 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 + * @return ChildAddressQuery 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); + $this->addUsingAlias(AddressTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AddressTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -841,32 +821,31 @@ abstract class BaseAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AddressTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Customer object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Customer|ObjectCollection $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. + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByCustomer($customer, $comparison = null) { - if ($customer instanceof Customer) { + if ($customer instanceof \Thelia\Model\Customer) { return $this - ->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->getId(), $comparison); - } elseif ($customer instanceof PropelObjectCollection) { + ->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customer->getId(), $comparison); + } elseif ($customer instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AddressTableMap::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection'); + throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection'); } } @@ -876,7 +855,7 @@ abstract class BaseAddressQuery extends ModelCriteria * @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 + * @return ChildAddressQuery The current query, for fluid interface */ public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -905,7 +884,7 @@ abstract class BaseAddressQuery extends ModelCriteria /** * Use the Customer relation Customer object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -921,28 +900,27 @@ abstract class BaseAddressQuery extends ModelCriteria } /** - * Filter the query by a related CustomerTitle object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\CustomerTitle|ObjectCollection $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. + * @return ChildAddressQuery The current query, for fluid interface */ public function filterByCustomerTitle($customerTitle, $comparison = null) { - if ($customerTitle instanceof CustomerTitle) { + if ($customerTitle instanceof \Thelia\Model\CustomerTitle) { return $this - ->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison); - } elseif ($customerTitle instanceof PropelObjectCollection) { + ->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison); + } elseif ($customerTitle instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AddressTableMap::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection'); + throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection'); } } @@ -952,7 +930,7 @@ abstract class BaseAddressQuery extends ModelCriteria * @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 + * @return ChildAddressQuery The current query, for fluid interface */ public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -981,7 +959,7 @@ abstract class BaseAddressQuery extends ModelCriteria /** * Use the CustomerTitle relation CustomerTitle object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -999,19 +977,94 @@ abstract class BaseAddressQuery extends ModelCriteria /** * Exclude object from result * - * @param Address $address Object to remove from the list of results + * @param ChildAddress $address Object to remove from the list of results * - * @return AddressQuery The current query, for fluid interface + * @return ChildAddressQuery The current query, for fluid interface */ public function prune($address = null) { if ($address) { - $this->addUsingAlias(AddressPeer::ID, $address->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(AddressTableMap::ID, $address->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the address table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AddressTableMap::clearInstancePool(); + AddressTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAddress or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAddress object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AddressTableMap::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(); + + + AddressTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AddressTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -1019,31 +1072,11 @@ abstract class BaseAddressQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AddressQuery The current query, for fluid interface + * @return ChildAddressQuery 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); + return $this->addUsingAlias(AddressTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -1051,30 +1084,51 @@ abstract class BaseAddressQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AddressQuery The current query, for fluid interface + * @return ChildAddressQuery 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); + return $this->addUsingAlias(AddressTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAddressQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AddressTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAddressQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AddressTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AddressQuery The current query, for fluid interface + * @return ChildAddressQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AddressPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AddressTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AddressQuery The current query, for fluid interface + * @return ChildAddressQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AddressPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AddressTableMap::CREATED_AT); } -} + +} // AddressQuery diff --git a/core/lib/Thelia/Model/om/BaseAdmin.php b/core/lib/Thelia/Model/Base/Admin.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseAdmin.php rename to core/lib/Thelia/Model/Base/Admin.php index 5bf15b3ff..b1241473e --- a/core/lib/Thelia/Model/om/BaseAdmin.php +++ b/core/lib/Thelia/Model/Base/Admin.php @@ -1,55 +1,63 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Admin instance. If + * obj is an instance of Admin, delegates to + * equals(Admin). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Admin The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Admin The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [firstname] column value. * - * @return string + * @return string */ public function getFirstname() { + return $this->firstname; } /** * Get the [lastname] column value. * - * @return string + * @return string */ public function getLastname() { + return $this->lastname; } /** * Get the [login] column value. * - * @return string + * @return string */ public function getLogin() { + return $this->login; } /** * Get the [password] column value. * - * @return string + * @return string */ public function getPassword() { + return $this->password; } /** * Get the [algo] column value. * - * @return string + * @return string */ public function getAlgo() { + return $this->algo; } /** * Get the [salt] column value. * - * @return string + * @return string */ public function getSalt() { + return $this->salt; } @@ -222,97 +479,57 @@ abstract class BaseAdmin extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Admin The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = AdminPeer::ID; + $this->modifiedColumns[] = AdminTableMap::ID; } @@ -322,18 +539,18 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Set the value of [firstname] column. * - * @param string $v new value - * @return Admin The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Admin The current object (for fluent API support) */ public function setFirstname($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->firstname !== $v) { $this->firstname = $v; - $this->modifiedColumns[] = AdminPeer::FIRSTNAME; + $this->modifiedColumns[] = AdminTableMap::FIRSTNAME; } @@ -343,18 +560,18 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Set the value of [lastname] column. * - * @param string $v new value - * @return Admin The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Admin The current object (for fluent API support) */ public function setLastname($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->lastname !== $v) { $this->lastname = $v; - $this->modifiedColumns[] = AdminPeer::LASTNAME; + $this->modifiedColumns[] = AdminTableMap::LASTNAME; } @@ -364,18 +581,18 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Set the value of [login] column. * - * @param string $v new value - * @return Admin The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Admin The current object (for fluent API support) */ public function setLogin($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->login !== $v) { $this->login = $v; - $this->modifiedColumns[] = AdminPeer::LOGIN; + $this->modifiedColumns[] = AdminTableMap::LOGIN; } @@ -385,18 +602,18 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Set the value of [password] column. * - * @param string $v new value - * @return Admin The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Admin The current object (for fluent API support) */ public function setPassword($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->password !== $v) { $this->password = $v; - $this->modifiedColumns[] = AdminPeer::PASSWORD; + $this->modifiedColumns[] = AdminTableMap::PASSWORD; } @@ -406,18 +623,18 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Set the value of [algo] column. * - * @param string $v new value - * @return Admin The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Admin The current object (for fluent API support) */ public function setAlgo($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->algo !== $v) { $this->algo = $v; - $this->modifiedColumns[] = AdminPeer::ALGO; + $this->modifiedColumns[] = AdminTableMap::ALGO; } @@ -427,18 +644,18 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Set the value of [salt] column. * - * @param string $v new value - * @return Admin The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Admin The current object (for fluent API support) */ public function setSalt($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->salt !== $v) { $this->salt = $v; - $this->modifiedColumns[] = AdminPeer::SALT; + $this->modifiedColumns[] = AdminTableMap::SALT; } @@ -448,19 +665,17 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Admin The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AdminTableMap::CREATED_AT; } } // if either are not null @@ -471,19 +686,17 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Admin The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AdminTableMap::UPDATED_AT; } } // if either are not null @@ -501,7 +714,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -513,25 +726,53 @@ abstract class BaseAdmin extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AdminTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AdminTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->firstname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AdminTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lastname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AdminTableMap::translateFieldName('Login', TableMap::TYPE_PHPNAME, $indexType)]; + $this->login = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AdminTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; + $this->password = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AdminTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->algo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AdminTableMap::translateFieldName('Salt', TableMap::TYPE_PHPNAME, $indexType)]; + $this->salt = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : AdminTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -539,11 +780,11 @@ abstract class BaseAdmin extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 9; // 9 = AdminPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 9; // 9 = AdminTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Admin object", $e); + throw new PropelException("Error populating \Thelia\Model\Admin object", 0, $e); } } @@ -562,7 +803,6 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -570,12 +810,12 @@ abstract class BaseAdmin extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -586,19 +826,19 @@ abstract class BaseAdmin extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AdminTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildAdminQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -611,26 +851,25 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Admin::setDeleted() + * @see Admin::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = AdminQuery::create() + $deleteQuery = ChildAdminQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -655,20 +894,19 @@ abstract class BaseAdmin extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -678,16 +916,16 @@ abstract class BaseAdmin extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(AdminPeer::CREATED_AT)) { + if (!$this->isColumnModified(AdminTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(AdminPeer::UPDATED_AT)) { + if (!$this->isColumnModified(AdminTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AdminPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(AdminTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -699,7 +937,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - AdminPeer::addInstanceToPool($this); + AdminTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -718,12 +956,12 @@ abstract class BaseAdmin extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -743,10 +981,11 @@ abstract class BaseAdmin extends BaseObject implements Persistent if ($this->groupsScheduledForDeletion !== null) { if (!$this->groupsScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->groupsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($remotePk, $pk); } + AdminGroupQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -768,15 +1007,15 @@ abstract class BaseAdmin extends BaseObject implements Persistent if ($this->adminGroupsScheduledForDeletion !== null) { if (!$this->adminGroupsScheduledForDeletion->isEmpty()) { - AdminGroupQuery::create() + \Thelia\Model\AdminGroupQuery::create() ->filterByPrimaryKeys($this->adminGroupsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->adminGroupsScheduledForDeletion = null; } } - if ($this->collAdminGroups !== null) { - foreach ($this->collAdminGroups as $referrerFK) { + if ($this->collAdminGroups !== null) { + foreach ($this->collAdminGroups as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -793,52 +1032,52 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = AdminPeer::ID; + $this->modifiedColumns[] = AdminTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AdminPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(AdminTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(AdminPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`firstname`'; + if ($this->isColumnModified(AdminTableMap::FIRSTNAME)) { + $modifiedColumns[':p' . $index++] = 'FIRSTNAME'; } - if ($this->isColumnModified(AdminPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`lastname`'; + if ($this->isColumnModified(AdminTableMap::LASTNAME)) { + $modifiedColumns[':p' . $index++] = 'LASTNAME'; } - if ($this->isColumnModified(AdminPeer::LOGIN)) { - $modifiedColumns[':p' . $index++] = '`login`'; + if ($this->isColumnModified(AdminTableMap::LOGIN)) { + $modifiedColumns[':p' . $index++] = 'LOGIN'; } - if ($this->isColumnModified(AdminPeer::PASSWORD)) { - $modifiedColumns[':p' . $index++] = '`password`'; + if ($this->isColumnModified(AdminTableMap::PASSWORD)) { + $modifiedColumns[':p' . $index++] = 'PASSWORD'; } - if ($this->isColumnModified(AdminPeer::ALGO)) { - $modifiedColumns[':p' . $index++] = '`algo`'; + if ($this->isColumnModified(AdminTableMap::ALGO)) { + $modifiedColumns[':p' . $index++] = 'ALGO'; } - if ($this->isColumnModified(AdminPeer::SALT)) { - $modifiedColumns[':p' . $index++] = '`salt`'; + if ($this->isColumnModified(AdminTableMap::SALT)) { + $modifiedColumns[':p' . $index++] = 'SALT'; } - if ($this->isColumnModified(AdminPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(AdminTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(AdminPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(AdminTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `admin` (%s) VALUES (%s)', + 'INSERT INTO admin (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -847,45 +1086,45 @@ abstract class BaseAdmin extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`firstname`': + case 'FIRSTNAME': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; - case '`lastname`': + case 'LASTNAME': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; - case '`login`': + case 'LOGIN': $stmt->bindValue($identifier, $this->login, PDO::PARAM_STR); break; - case '`password`': + case 'PASSWORD': $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); break; - case '`algo`': + case 'ALGO': $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR); break; - case '`salt`': + case 'SALT': $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -895,112 +1134,32 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = AdminPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = AdminTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1010,7 +1169,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1055,22 +1214,22 @@ abstract class BaseAdmin extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = AdminTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getFirstname(), @@ -1082,6 +1241,12 @@ abstract class BaseAdmin extends BaseObject implements Persistent $keys[7] => $this->getCreatedAt(), $keys[8] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collAdminGroups) { $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1094,27 +1259,27 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = AdminPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = AdminTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1159,17 +1324,17 @@ abstract class BaseAdmin extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = AdminPeer::getFieldNames($keyType); + $keys = AdminTableMap::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]]); @@ -1189,17 +1354,17 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(AdminPeer::DATABASE_NAME); + $criteria = new Criteria(AdminTableMap::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); + if ($this->isColumnModified(AdminTableMap::ID)) $criteria->add(AdminTableMap::ID, $this->id); + if ($this->isColumnModified(AdminTableMap::FIRSTNAME)) $criteria->add(AdminTableMap::FIRSTNAME, $this->firstname); + if ($this->isColumnModified(AdminTableMap::LASTNAME)) $criteria->add(AdminTableMap::LASTNAME, $this->lastname); + if ($this->isColumnModified(AdminTableMap::LOGIN)) $criteria->add(AdminTableMap::LOGIN, $this->login); + if ($this->isColumnModified(AdminTableMap::PASSWORD)) $criteria->add(AdminTableMap::PASSWORD, $this->password); + if ($this->isColumnModified(AdminTableMap::ALGO)) $criteria->add(AdminTableMap::ALGO, $this->algo); + if ($this->isColumnModified(AdminTableMap::SALT)) $criteria->add(AdminTableMap::SALT, $this->salt); + if ($this->isColumnModified(AdminTableMap::CREATED_AT)) $criteria->add(AdminTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AdminTableMap::UPDATED_AT)) $criteria->add(AdminTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1214,15 +1379,15 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(AdminPeer::DATABASE_NAME); - $criteria->add(AdminPeer::ID, $this->id); + $criteria = new Criteria(AdminTableMap::DATABASE_NAME); + $criteria->add(AdminTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1232,7 +1397,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1256,9 +1421,9 @@ abstract class BaseAdmin extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1272,12 +1437,10 @@ abstract class BaseAdmin extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1285,8 +1448,6 @@ abstract class BaseAdmin extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1303,8 +1464,8 @@ abstract class BaseAdmin extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Admin Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1317,37 +1478,19 @@ abstract class BaseAdmin extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('AdminGroup' == $relationName) { - $this->initAdminGroups(); + return $this->initAdminGroups(); } } @@ -1357,21 +1500,16 @@ abstract class BaseAdmin extends BaseObject implements Persistent * This 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) + * @return void * @see addAdminGroups() */ public function clearAdminGroups() { - $this->collAdminGroups = null; // important to set this to null since that means it is uninitialized - $this->collAdminGroupsPartial = null; - - return $this; + $this->collAdminGroups = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collAdminGroups collection loaded partially - * - * @return void + * Reset is the collAdminGroups collection loaded partially. */ public function resetPartialAdminGroups($v = true) { @@ -1385,7 +1523,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1395,25 +1533,25 @@ abstract class BaseAdmin extends BaseObject implements Persistent if (null !== $this->collAdminGroups && !$overrideExisting) { return; } - $this->collAdminGroups = new PropelObjectCollection(); - $this->collAdminGroups->setModel('AdminGroup'); + $this->collAdminGroups = new ObjectCollection(); + $this->collAdminGroups->setModel('\Thelia\Model\AdminGroup'); } /** - * Gets an array of AdminGroup objects which contain a foreign key that references this object. + * Gets an array of ChildAdminGroup objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildAdmin is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects * @throws PropelException */ - public function getAdminGroups($criteria = null, PropelPDO $con = null) + public function getAdminGroups($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAdminGroupsPartial && !$this->isNew(); if (null === $this->collAdminGroups || null !== $criteria || $partial) { @@ -1421,29 +1559,31 @@ abstract class BaseAdmin extends BaseObject implements Persistent // return empty collection $this->initAdminGroups(); } else { - $collAdminGroups = AdminGroupQuery::create(null, $criteria) + $collAdminGroups = ChildAdminGroupQuery::create(null, $criteria) ->filterByAdmin($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) { - $this->initAdminGroups(false); + $this->initAdminGroups(false); - foreach($collAdminGroups as $obj) { - if (false == $this->collAdminGroups->contains($obj)) { - $this->collAdminGroups->append($obj); + foreach ($collAdminGroups as $obj) { + if (false == $this->collAdminGroups->contains($obj)) { + $this->collAdminGroups->append($obj); + } } - } - $this->collAdminGroupsPartial = true; + $this->collAdminGroupsPartial = true; } $collAdminGroups->getInternalIterator()->rewind(); + return $collAdminGroups; } - if($partial && $this->collAdminGroups) { - foreach($this->collAdminGroups as $obj) { - if($obj->isNew()) { + if ($partial && $this->collAdminGroups) { + foreach ($this->collAdminGroups as $obj) { + if ($obj->isNew()) { $collAdminGroups[] = $obj; } } @@ -1463,15 +1603,19 @@ abstract class BaseAdmin extends BaseObject implements Persistent * It will 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) + * @param Collection $adminGroups A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildAdmin The current object (for fluent API support) */ - public function setAdminGroups(PropelCollection $adminGroups, PropelPDO $con = null) + public function setAdminGroups(Collection $adminGroups, ConnectionInterface $con = null) { $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); - $this->adminGroupsScheduledForDeletion = unserialize(serialize($adminGroupsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->adminGroupsScheduledForDeletion = clone $adminGroupsToDelete; foreach ($adminGroupsToDelete as $adminGroupRemoved) { $adminGroupRemoved->setAdmin(null); @@ -1491,13 +1635,13 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * Returns the number of related AdminGroup objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AdminGroup objects. * @throws PropelException */ - public function countAdminGroups(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAdminGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAdminGroupsPartial && !$this->isNew(); if (null === $this->collAdminGroups || null !== $criteria || $partial) { @@ -1505,10 +1649,11 @@ abstract class BaseAdmin extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getAdminGroups()); } - $query = AdminGroupQuery::create(null, $criteria); + + $query = ChildAdminGroupQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1522,18 +1667,19 @@ abstract class BaseAdmin extends BaseObject implements Persistent } /** - * Method called to associate a AdminGroup object to this object - * through the AdminGroup foreign key attribute. + * Method called to associate a ChildAdminGroup object to this object + * through the ChildAdminGroup foreign key attribute. * - * @param AdminGroup $l AdminGroup - * @return Admin The current object (for fluent API support) + * @param ChildAdminGroup $l ChildAdminGroup + * @return \Thelia\Model\Admin The current object (for fluent API support) */ - public function addAdminGroup(AdminGroup $l) + public function addAdminGroup(ChildAdminGroup $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); } @@ -1542,7 +1688,7 @@ abstract class BaseAdmin extends BaseObject implements Persistent } /** - * @param AdminGroup $adminGroup The adminGroup object to add. + * @param AdminGroup $adminGroup The adminGroup object to add. */ protected function doAddAdminGroup($adminGroup) { @@ -1551,8 +1697,8 @@ abstract class BaseAdmin extends BaseObject implements Persistent } /** - * @param AdminGroup $adminGroup The adminGroup object to remove. - * @return Admin The current object (for fluent API support) + * @param AdminGroup $adminGroup The adminGroup object to remove. + * @return ChildAdmin The current object (for fluent API support) */ public function removeAdminGroup($adminGroup) { @@ -1581,15 +1727,15 @@ abstract class BaseAdmin extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects */ - public function getAdminGroupsJoinGroup($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAdminGroupsJoinGroup($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AdminGroupQuery::create(null, $criteria); - $query->joinWith('Group', $join_behavior); + $query = ChildAdminGroupQuery::create(null, $criteria); + $query->joinWith('Group', $joinBehavior); return $this->getAdminGroups($query, $con); } @@ -1600,15 +1746,13 @@ abstract class BaseAdmin extends BaseObject implements Persistent * This 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) + * @return void * @see addGroups() */ public function clearGroups() { - $this->collGroups = null; // important to set this to null since that means it is uninitialized + $this->collGroups = null; // important to set this to NULL since that means it is uninitialized $this->collGroupsPartial = null; - - return $this; } /** @@ -1622,33 +1766,33 @@ abstract class BaseAdmin extends BaseObject implements Persistent */ public function initGroups() { - $this->collGroups = new PropelObjectCollection(); - $this->collGroups->setModel('Group'); + $this->collGroups = new ObjectCollection(); + $this->collGroups->setModel('\Thelia\Model\Group'); } /** - * Gets a collection of Group objects related by a many-to-many relationship + * Gets a collection of ChildGroup 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 + * If this ChildAdmin 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Group[] List of Group objects + * @return ObjectCollection|ChildGroup[] List of ChildGroup objects */ - public function getGroups($criteria = null, PropelPDO $con = null) + public function getGroups($criteria = null, ConnectionInterface $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) + $collGroups = ChildGroupQuery::create(null, $criteria) ->filterByAdmin($this) ->find($con); if (null !== $criteria) { @@ -1667,11 +1811,11 @@ abstract class BaseAdmin extends BaseObject implements Persistent * It will 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) + * @param Collection $groups A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildAdmin The current object (for fluent API support) */ - public function setGroups(PropelCollection $groups, PropelPDO $con = null) + public function setGroups(Collection $groups, ConnectionInterface $con = null) { $this->clearGroups(); $currentGroups = $this->getGroups(); @@ -1690,22 +1834,22 @@ abstract class BaseAdmin extends BaseObject implements Persistent } /** - * Gets the number of Group objects related by a many-to-many relationship + * Gets the number of ChildGroup 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Group objects + * @return int the number of related ChildGroup objects */ - public function countGroups($criteria = null, $distinct = false, PropelPDO $con = null) + public function countGroups($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collGroups || null !== $criteria) { if ($this->isNew() && null === $this->collGroups) { return 0; } else { - $query = GroupQuery::create(null, $criteria); + $query = ChildGroupQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1720,52 +1864,60 @@ abstract class BaseAdmin extends BaseObject implements Persistent } /** - * Associate a Group object to this object + * Associate a ChildGroup 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) + * @param ChildGroup $group The ChildAdminGroup object to relate + * @return ChildAdmin The current object (for fluent API support) */ - public function addGroup(Group $group) + public function addGroup(ChildGroup $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; + $this->collGroups[] = $group; } return $this; } /** - * @param Group $group The group object to add. + * @param Group $group The group object to add. */ protected function doAddGroup($group) { - $adminGroup = new AdminGroup(); + $adminGroup = new ChildAdminGroup(); $adminGroup->setGroup($group); $this->addAdminGroup($adminGroup); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$group->getAdmins()->contains($this)) { + $foreignCollection = $group->getAdmins(); + $foreignCollection[] = $this; + } } /** - * Remove a Group object to this object + * Remove a ChildGroup 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) + * @param ChildGroup $group The ChildAdminGroup object to relate + * @return ChildAdmin The current object (for fluent API support) */ - public function removeGroup(Group $group) + public function removeGroup(ChildGroup $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; + + $this->groupsScheduledForDeletion[] = $group; } return $this; @@ -1786,8 +1938,6 @@ abstract class BaseAdmin extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1799,14 +1949,13 @@ abstract class BaseAdmin extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collAdminGroups) { foreach ($this->collAdminGroups as $o) { $o->clearAllReferences($deep); @@ -1817,38 +1966,26 @@ abstract class BaseAdmin extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) - if ($this->collAdminGroups instanceof PropelCollection) { + if ($this->collAdminGroups instanceof Collection) { $this->collAdminGroups->clearIterator(); } $this->collAdminGroups = null; - if ($this->collGroups instanceof PropelCollection) { + if ($this->collGroups instanceof Collection) { $this->collGroups->clearIterator(); } $this->collGroups = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(AdminTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1856,13 +1993,131 @@ abstract class BaseAdmin extends BaseObject implements Persistent /** * 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) + * @return ChildAdmin The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = AdminPeer::UPDATED_AT; + $this->modifiedColumns[] = AdminTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/AdminGroup.php b/core/lib/Thelia/Model/Base/AdminGroup.php new file mode 100644 index 000000000..60141e3f8 --- /dev/null +++ b/core/lib/Thelia/Model/Base/AdminGroup.php @@ -0,0 +1,1505 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another AdminGroup instance. If + * obj is an instance of AdminGroup, delegates to + * equals(AdminGroup). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return AdminGroup The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return AdminGroup The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 [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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\AdminGroup The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AdminGroupTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [group_id] column. + * + * @param int $v new value + * @return \Thelia\Model\AdminGroup The current object (for fluent API support) + */ + public function setGroupId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->group_id !== $v) { + $this->group_id = $v; + $this->modifiedColumns[] = AdminGroupTableMap::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 \Thelia\Model\AdminGroup The current object (for fluent API support) + */ + public function setAdminId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->admin_id !== $v) { + $this->admin_id = $v; + $this->modifiedColumns[] = AdminGroupTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AdminGroupTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AdminGroupTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AdminGroupTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AdminGroupTableMap::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->group_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AdminGroupTableMap::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->admin_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AdminGroupTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AdminGroupTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = AdminGroupTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\AdminGroup object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(AdminGroupTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildAdminGroupQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see AdminGroup::setDeleted() + * @see AdminGroup::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildAdminGroupQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AdminGroupTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + AdminGroupTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = AdminGroupTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminGroupTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AdminGroupTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(AdminGroupTableMap::GROUP_ID)) { + $modifiedColumns[':p' . $index++] = 'GROUP_ID'; + } + if ($this->isColumnModified(AdminGroupTableMap::ADMIN_ID)) { + $modifiedColumns[':p' . $index++] = 'ADMIN_ID'; + } + if ($this->isColumnModified(AdminGroupTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(AdminGroupTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = AdminGroupTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['AdminGroup'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['AdminGroup'][serialize($this->getPrimaryKey())] = true; + $keys = AdminGroupTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getGroupId(), + $keys[2] => $this->getAdminId(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = AdminGroupTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = AdminGroupTableMap::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(AdminGroupTableMap::DATABASE_NAME); + + if ($this->isColumnModified(AdminGroupTableMap::ID)) $criteria->add(AdminGroupTableMap::ID, $this->id); + if ($this->isColumnModified(AdminGroupTableMap::GROUP_ID)) $criteria->add(AdminGroupTableMap::GROUP_ID, $this->group_id); + if ($this->isColumnModified(AdminGroupTableMap::ADMIN_ID)) $criteria->add(AdminGroupTableMap::ADMIN_ID, $this->admin_id); + if ($this->isColumnModified(AdminGroupTableMap::CREATED_AT)) $criteria->add(AdminGroupTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) $criteria->add(AdminGroupTableMap::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(AdminGroupTableMap::DATABASE_NAME); + $criteria->add(AdminGroupTableMap::ID, $this->id); + $criteria->add(AdminGroupTableMap::GROUP_ID, $this->group_id); + $criteria->add(AdminGroupTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildGroup object. + * + * @param ChildGroup $v + * @return \Thelia\Model\AdminGroup The current object (for fluent API support) + * @throws PropelException + */ + public function setGroup(ChildGroup $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 ChildGroup object, it will not be re-added. + if ($v !== null) { + $v->addAdminGroup($this); + } + + + return $this; + } + + + /** + * Get the associated ChildGroup object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildGroup The associated ChildGroup object. + * @throws PropelException + */ + public function getGroup(ConnectionInterface $con = null) + { + if ($this->aGroup === null && ($this->group_id !== null)) { + $this->aGroup = ChildGroupQuery::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 ChildAdmin object. + * + * @param ChildAdmin $v + * @return \Thelia\Model\AdminGroup The current object (for fluent API support) + * @throws PropelException + */ + public function setAdmin(ChildAdmin $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 ChildAdmin object, it will not be re-added. + if ($v !== null) { + $v->addAdminGroup($this); + } + + + return $this; + } + + + /** + * Get the associated ChildAdmin object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildAdmin The associated ChildAdmin object. + * @throws PropelException + */ + public function getAdmin(ConnectionInterface $con = null) + { + if ($this->aAdmin === null && ($this->admin_id !== null)) { + $this->aAdmin = ChildAdminQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aGroup = null; + $this->aAdmin = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AdminGroupTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildAdminGroup The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AdminGroupTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php b/core/lib/Thelia/Model/Base/AdminGroupQuery.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseAdminGroupQuery.php rename to core/lib/Thelia/Model/Base/AdminGroupQuery.php index fa37ae6f6..8d3353b4c --- a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php +++ b/core/lib/Thelia/Model/Base/AdminGroupQuery.php @@ -1,97 +1,95 @@ setModelAlias($modelAlias); } @@ -111,23 +109,22 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * $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 + * @param array[$id, $group_id, $admin_id] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return AdminGroup|AdminGroup[]|mixed the result, formatted by the current formatter + * @return ChildAdminGroup|array|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 + if ((null !== ($obj = AdminGroupTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AdminGroupTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -144,14 +141,13 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return AdminGroup A model object, or null if the key is not found - * @throws PropelException + * @return ChildAdminGroup A model object, or null if the key is not found */ 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'; + $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); @@ -160,13 +156,13 @@ abstract class BaseAdminGroupQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AdminGroup(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAdminGroup(); $obj->hydrate($row); - AdminGroupPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); + AdminGroupTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); } $stmt->closeCursor(); @@ -177,19 +173,19 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return AdminGroup|AdminGroup[]|mixed the result, formatted by the current formatter + * @return ChildAdminGroup|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -198,22 +194,22 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|AdminGroup[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -221,13 +217,13 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AdminGroupQuery The current query, for fluid interface + * @return ChildAdminGroupQuery 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); + $this->addUsingAlias(AdminGroupTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $key[1], Criteria::EQUAL); + $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $key[2], Criteria::EQUAL); return $this; } @@ -237,7 +233,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AdminGroupQuery The current query, for fluid interface + * @return ChildAdminGroupQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -245,10 +241,10 @@ abstract class BaseAdminGroupQuery extends ModelCriteria 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 = $this->getNewCriterion(AdminGroupTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(AdminGroupTableMap::GROUP_ID, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); - $cton2 = $this->getNewCriterion(AdminGroupPeer::ADMIN_ID, $key[2], Criteria::EQUAL); + $cton2 = $this->getNewCriterion(AdminGroupTableMap::ADMIN_ID, $key[2], Criteria::EQUAL); $cton0->addAnd($cton2); $this->addOr($cton0); } @@ -263,8 +259,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -273,18 +268,18 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * 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 + * @return ChildAdminGroupQuery 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); + $this->addUsingAlias(AdminGroupTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AdminGroupPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminGroupTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -295,7 +290,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminGroupPeer::ID, $id, $comparison); + return $this->addUsingAlias(AdminGroupTableMap::ID, $id, $comparison); } /** @@ -305,8 +300,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * $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 + * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12 * * * @see filterByGroup() @@ -317,18 +311,18 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * 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 + * @return ChildAdminGroupQuery 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); + $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($groupId['max'])) { - $this->addUsingAlias(AdminGroupPeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -339,7 +333,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminGroupPeer::GROUP_ID, $groupId, $comparison); + return $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $groupId, $comparison); } /** @@ -349,8 +343,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * $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 + * $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12 * * * @see filterByAdmin() @@ -361,18 +354,18 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * 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 + * @return ChildAdminGroupQuery 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); + $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $adminId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($adminId['max'])) { - $this->addUsingAlias(AdminGroupPeer::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -383,7 +376,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminGroupPeer::ADMIN_ID, $adminId, $comparison); + return $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $adminId, $comparison); } /** @@ -404,18 +397,18 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * 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 + * @return ChildAdminGroupQuery 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); + $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AdminGroupPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -426,7 +419,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminGroupPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -447,18 +440,18 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * 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 + * @return ChildAdminGroupQuery 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); + $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -469,32 +462,31 @@ abstract class BaseAdminGroupQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Group object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Group|ObjectCollection $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. + * @return ChildAdminGroupQuery The current query, for fluid interface */ public function filterByGroup($group, $comparison = null) { - if ($group instanceof Group) { + if ($group instanceof \Thelia\Model\Group) { return $this - ->addUsingAlias(AdminGroupPeer::GROUP_ID, $group->getId(), $comparison); - } elseif ($group instanceof PropelObjectCollection) { + ->addUsingAlias(AdminGroupTableMap::GROUP_ID, $group->getId(), $comparison); + } elseif ($group instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AdminGroupPeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AdminGroupTableMap::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection'); + throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection'); } } @@ -504,7 +496,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * @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 + * @return ChildAdminGroupQuery The current query, for fluid interface */ public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -533,7 +525,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria /** * Use the Group relation Group object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -549,28 +541,27 @@ abstract class BaseAdminGroupQuery extends ModelCriteria } /** - * Filter the query by a related Admin object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Admin|ObjectCollection $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. + * @return ChildAdminGroupQuery The current query, for fluid interface */ public function filterByAdmin($admin, $comparison = null) { - if ($admin instanceof Admin) { + if ($admin instanceof \Thelia\Model\Admin) { return $this - ->addUsingAlias(AdminGroupPeer::ADMIN_ID, $admin->getId(), $comparison); - } elseif ($admin instanceof PropelObjectCollection) { + ->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $admin->getId(), $comparison); + } elseif ($admin instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AdminGroupPeer::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByAdmin() only accepts arguments of type Admin or PropelCollection'); + throw new PropelException('filterByAdmin() only accepts arguments of type \Thelia\Model\Admin or Collection'); } } @@ -580,7 +571,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * @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 + * @return ChildAdminGroupQuery The current query, for fluid interface */ public function joinAdmin($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -609,7 +600,7 @@ abstract class BaseAdminGroupQuery extends ModelCriteria /** * Use the Admin relation Admin object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -627,22 +618,97 @@ abstract class BaseAdminGroupQuery extends ModelCriteria /** * Exclude object from result * - * @param AdminGroup $adminGroup Object to remove from the list of results + * @param ChildAdminGroup $adminGroup Object to remove from the list of results * - * @return AdminGroupQuery The current query, for fluid interface + * @return ChildAdminGroupQuery 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->addCond('pruneCond0', $this->getAliasedColName(AdminGroupTableMap::ID), $adminGroup->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(AdminGroupTableMap::GROUP_ID), $adminGroup->getGroupId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond2', $this->getAliasedColName(AdminGroupTableMap::ADMIN_ID), $adminGroup->getAdminId(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); } return $this; } + /** + * Deletes all rows from the admin_group table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AdminGroupTableMap::clearInstancePool(); + AdminGroupTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAdminGroup or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAdminGroup object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AdminGroupTableMap::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(); + + + AdminGroupTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AdminGroupTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -650,31 +716,11 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AdminGroupQuery The current query, for fluid interface + * @return ChildAdminGroupQuery 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); + return $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -682,30 +728,51 @@ abstract class BaseAdminGroupQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AdminGroupQuery The current query, for fluid interface + * @return ChildAdminGroupQuery 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); + return $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAdminGroupQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AdminGroupTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAdminGroupQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AdminGroupTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AdminGroupQuery The current query, for fluid interface + * @return ChildAdminGroupQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AdminGroupPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AdminGroupTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AdminGroupQuery The current query, for fluid interface + * @return ChildAdminGroupQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AdminGroupPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AdminGroupTableMap::CREATED_AT); } -} + +} // AdminGroupQuery diff --git a/core/lib/Thelia/Model/Base/AdminLog.php b/core/lib/Thelia/Model/Base/AdminLog.php new file mode 100644 index 000000000..c83be20ee --- /dev/null +++ b/core/lib/Thelia/Model/Base/AdminLog.php @@ -0,0 +1,1507 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another AdminLog instance. If + * obj is an instance of AdminLog, delegates to + * equals(AdminLog). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return AdminLog The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return AdminLog The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\AdminLog The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AdminLogTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [admin_login] column. + * + * @param string $v new value + * @return \Thelia\Model\AdminLog The current object (for fluent API support) + */ + public function setAdminLogin($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->admin_login !== $v) { + $this->admin_login = $v; + $this->modifiedColumns[] = AdminLogTableMap::ADMIN_LOGIN; + } + + + return $this; + } // setAdminLogin() + + /** + * Set the value of [admin_firstname] column. + * + * @param string $v new value + * @return \Thelia\Model\AdminLog The current object (for fluent API support) + */ + public function setAdminFirstname($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->admin_firstname !== $v) { + $this->admin_firstname = $v; + $this->modifiedColumns[] = AdminLogTableMap::ADMIN_FIRSTNAME; + } + + + return $this; + } // setAdminFirstname() + + /** + * Set the value of [admin_lastname] column. + * + * @param string $v new value + * @return \Thelia\Model\AdminLog The current object (for fluent API support) + */ + public function setAdminLastname($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->admin_lastname !== $v) { + $this->admin_lastname = $v; + $this->modifiedColumns[] = AdminLogTableMap::ADMIN_LASTNAME; + } + + + return $this; + } // setAdminLastname() + + /** + * Set the value of [action] column. + * + * @param string $v new value + * @return \Thelia\Model\AdminLog The current object (for fluent API support) + */ + public function setAction($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->action !== $v) { + $this->action = $v; + $this->modifiedColumns[] = AdminLogTableMap::ACTION; + } + + + return $this; + } // setAction() + + /** + * Set the value of [request] column. + * + * @param string $v new value + * @return \Thelia\Model\AdminLog The current object (for fluent API support) + */ + public function setRequest($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->request !== $v) { + $this->request = $v; + $this->modifiedColumns[] = AdminLogTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AdminLogTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AdminLogTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AdminLogTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AdminLogTableMap::translateFieldName('AdminLogin', TableMap::TYPE_PHPNAME, $indexType)]; + $this->admin_login = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AdminLogTableMap::translateFieldName('AdminFirstname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->admin_firstname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AdminLogTableMap::translateFieldName('AdminLastname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->admin_lastname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AdminLogTableMap::translateFieldName('Action', TableMap::TYPE_PHPNAME, $indexType)]; + $this->action = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AdminLogTableMap::translateFieldName('Request', TableMap::TYPE_PHPNAME, $indexType)]; + $this->request = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AdminLogTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : AdminLogTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 8; // 8 = AdminLogTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\AdminLog object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(AdminLogTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildAdminLogQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see AdminLog::setDeleted() + * @see AdminLog::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildAdminLogQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AdminLogTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AdminLogTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AdminLogTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + AdminLogTableMap::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 ConnectionInterface $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(ConnectionInterface $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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = AdminLogTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminLogTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AdminLogTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(AdminLogTableMap::ADMIN_LOGIN)) { + $modifiedColumns[':p' . $index++] = 'ADMIN_LOGIN'; + } + if ($this->isColumnModified(AdminLogTableMap::ADMIN_FIRSTNAME)) { + $modifiedColumns[':p' . $index++] = 'ADMIN_FIRSTNAME'; + } + if ($this->isColumnModified(AdminLogTableMap::ADMIN_LASTNAME)) { + $modifiedColumns[':p' . $index++] = 'ADMIN_LASTNAME'; + } + if ($this->isColumnModified(AdminLogTableMap::ACTION)) { + $modifiedColumns[':p' . $index++] = 'ACTION'; + } + if ($this->isColumnModified(AdminLogTableMap::REQUEST)) { + $modifiedColumns[':p' . $index++] = 'REQUEST'; + } + if ($this->isColumnModified(AdminLogTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(AdminLogTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = AdminLogTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['AdminLog'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['AdminLog'][$this->getPrimaryKey()] = true; + $keys = AdminLogTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = AdminLogTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = AdminLogTableMap::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(AdminLogTableMap::DATABASE_NAME); + + if ($this->isColumnModified(AdminLogTableMap::ID)) $criteria->add(AdminLogTableMap::ID, $this->id); + if ($this->isColumnModified(AdminLogTableMap::ADMIN_LOGIN)) $criteria->add(AdminLogTableMap::ADMIN_LOGIN, $this->admin_login); + if ($this->isColumnModified(AdminLogTableMap::ADMIN_FIRSTNAME)) $criteria->add(AdminLogTableMap::ADMIN_FIRSTNAME, $this->admin_firstname); + if ($this->isColumnModified(AdminLogTableMap::ADMIN_LASTNAME)) $criteria->add(AdminLogTableMap::ADMIN_LASTNAME, $this->admin_lastname); + if ($this->isColumnModified(AdminLogTableMap::ACTION)) $criteria->add(AdminLogTableMap::ACTION, $this->action); + if ($this->isColumnModified(AdminLogTableMap::REQUEST)) $criteria->add(AdminLogTableMap::REQUEST, $this->request); + if ($this->isColumnModified(AdminLogTableMap::CREATED_AT)) $criteria->add(AdminLogTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AdminLogTableMap::UPDATED_AT)) $criteria->add(AdminLogTableMap::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(AdminLogTableMap::DATABASE_NAME); + $criteria->add(AdminLogTableMap::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 \Thelia\Model\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 \Thelia\Model\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; + } + + /** + * 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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AdminLogTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildAdminLog The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AdminLogTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php b/core/lib/Thelia/Model/Base/AdminLogQuery.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseAdminLogQuery.php rename to core/lib/Thelia/Model/Base/AdminLogQuery.php index 00ff8548f..53a5849b5 --- a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php +++ b/core/lib/Thelia/Model/Base/AdminLogQuery.php @@ -1,96 +1,96 @@ setModelAlias($modelAlias); } @@ -111,21 +111,21 @@ abstract class BaseAdminLogQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return AdminLog|AdminLog[]|mixed the result, formatted by the current formatter + * @return ChildAdminLog|array|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 + if ((null !== ($obj = AdminLogTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AdminLogTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -137,46 +137,31 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return AdminLog A model object, or null if the key is not found - * @throws PropelException + * @return ChildAdminLog A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AdminLog(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAdminLog(); $obj->hydrate($row); - AdminLogPeer::addInstanceToPool($obj, (string) $key); + AdminLogTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -187,19 +172,19 @@ abstract class BaseAdminLogQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return AdminLog|AdminLog[]|mixed the result, formatted by the current formatter + * @return ChildAdminLog|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -208,22 +193,22 @@ abstract class BaseAdminLogQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|AdminLog[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -231,12 +216,12 @@ abstract class BaseAdminLogQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AdminLogQuery The current query, for fluid interface + * @return ChildAdminLogQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(AdminLogPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AdminLogTableMap::ID, $key, Criteria::EQUAL); } /** @@ -244,12 +229,12 @@ abstract class BaseAdminLogQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AdminLogQuery The current query, for fluid interface + * @return ChildAdminLogQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(AdminLogPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AdminLogTableMap::ID, $keys, Criteria::IN); } /** @@ -259,8 +244,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -269,18 +253,18 @@ abstract class BaseAdminLogQuery extends ModelCriteria * 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 + * @return ChildAdminLogQuery 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); + $this->addUsingAlias(AdminLogTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AdminLogPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminLogTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -291,7 +275,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminLogPeer::ID, $id, $comparison); + return $this->addUsingAlias(AdminLogTableMap::ID, $id, $comparison); } /** @@ -307,7 +291,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria * 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 + * @return ChildAdminLogQuery The current query, for fluid interface */ public function filterByAdminLogin($adminLogin = null, $comparison = null) { @@ -320,7 +304,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminLogPeer::ADMIN_LOGIN, $adminLogin, $comparison); + return $this->addUsingAlias(AdminLogTableMap::ADMIN_LOGIN, $adminLogin, $comparison); } /** @@ -336,7 +320,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria * 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 + * @return ChildAdminLogQuery The current query, for fluid interface */ public function filterByAdminFirstname($adminFirstname = null, $comparison = null) { @@ -349,7 +333,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminLogPeer::ADMIN_FIRSTNAME, $adminFirstname, $comparison); + return $this->addUsingAlias(AdminLogTableMap::ADMIN_FIRSTNAME, $adminFirstname, $comparison); } /** @@ -365,7 +349,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria * 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 + * @return ChildAdminLogQuery The current query, for fluid interface */ public function filterByAdminLastname($adminLastname = null, $comparison = null) { @@ -378,7 +362,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminLogPeer::ADMIN_LASTNAME, $adminLastname, $comparison); + return $this->addUsingAlias(AdminLogTableMap::ADMIN_LASTNAME, $adminLastname, $comparison); } /** @@ -394,7 +378,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria * 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 + * @return ChildAdminLogQuery The current query, for fluid interface */ public function filterByAction($action = null, $comparison = null) { @@ -407,7 +391,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminLogPeer::ACTION, $action, $comparison); + return $this->addUsingAlias(AdminLogTableMap::ACTION, $action, $comparison); } /** @@ -423,7 +407,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria * 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 + * @return ChildAdminLogQuery The current query, for fluid interface */ public function filterByRequest($request = null, $comparison = null) { @@ -436,7 +420,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminLogPeer::REQUEST, $request, $comparison); + return $this->addUsingAlias(AdminLogTableMap::REQUEST, $request, $comparison); } /** @@ -457,18 +441,18 @@ abstract class BaseAdminLogQuery extends ModelCriteria * 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 + * @return ChildAdminLogQuery 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); + $this->addUsingAlias(AdminLogTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AdminLogPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminLogTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -479,7 +463,7 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminLogPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AdminLogTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -500,18 +484,18 @@ abstract class BaseAdminLogQuery extends ModelCriteria * 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 + * @return ChildAdminLogQuery 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); + $this->addUsingAlias(AdminLogTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AdminLogPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminLogTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -522,25 +506,100 @@ abstract class BaseAdminLogQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminLogPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AdminLogTableMap::UPDATED_AT, $updatedAt, $comparison); } /** * Exclude object from result * - * @param AdminLog $adminLog Object to remove from the list of results + * @param ChildAdminLog $adminLog Object to remove from the list of results * - * @return AdminLogQuery The current query, for fluid interface + * @return ChildAdminLogQuery The current query, for fluid interface */ public function prune($adminLog = null) { if ($adminLog) { - $this->addUsingAlias(AdminLogPeer::ID, $adminLog->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(AdminLogTableMap::ID, $adminLog->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the admin_log table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AdminLogTableMap::clearInstancePool(); + AdminLogTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAdminLog or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAdminLog object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AdminLogTableMap::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(); + + + AdminLogTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AdminLogTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -548,31 +607,11 @@ abstract class BaseAdminLogQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AdminLogQuery The current query, for fluid interface + * @return ChildAdminLogQuery 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); + return $this->addUsingAlias(AdminLogTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -580,30 +619,51 @@ abstract class BaseAdminLogQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AdminLogQuery The current query, for fluid interface + * @return ChildAdminLogQuery 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); + return $this->addUsingAlias(AdminLogTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAdminLogQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AdminLogTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAdminLogQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AdminLogTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AdminLogQuery The current query, for fluid interface + * @return ChildAdminLogQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AdminLogPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AdminLogTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AdminLogQuery The current query, for fluid interface + * @return ChildAdminLogQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AdminLogPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AdminLogTableMap::CREATED_AT); } -} + +} // AdminLogQuery diff --git a/core/lib/Thelia/Model/om/BaseAdminQuery.php b/core/lib/Thelia/Model/Base/AdminQuery.php old mode 100755 new mode 100644 similarity index 54% rename from core/lib/Thelia/Model/om/BaseAdminQuery.php rename to core/lib/Thelia/Model/Base/AdminQuery.php index 9cce7e496..1ac79b4fe --- a/core/lib/Thelia/Model/om/BaseAdminQuery.php +++ b/core/lib/Thelia/Model/Base/AdminQuery.php @@ -1,108 +1,107 @@ setModelAlias($modelAlias); } @@ -123,21 +122,21 @@ abstract class BaseAdminQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Admin|Admin[]|mixed the result, formatted by the current formatter + * @return ChildAdmin|array|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 + if ((null !== ($obj = AdminTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AdminTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -149,46 +148,31 @@ abstract class BaseAdminQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Admin A model object, or null if the key is not found - * @throws PropelException + * @return ChildAdmin A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `firstname`, `lastname`, `login`, `password`, `algo`, `salt`, `created_at`, `updated_at` FROM `admin` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Admin(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAdmin(); $obj->hydrate($row); - AdminPeer::addInstanceToPool($obj, (string) $key); + AdminTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -199,19 +183,19 @@ abstract class BaseAdminQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Admin|Admin[]|mixed the result, formatted by the current formatter + * @return ChildAdmin|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -220,22 +204,22 @@ abstract class BaseAdminQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Admin[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -243,12 +227,12 @@ abstract class BaseAdminQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AdminQuery The current query, for fluid interface + * @return ChildAdminQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(AdminPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AdminTableMap::ID, $key, Criteria::EQUAL); } /** @@ -256,12 +240,12 @@ abstract class BaseAdminQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AdminQuery The current query, for fluid interface + * @return ChildAdminQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(AdminPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AdminTableMap::ID, $keys, Criteria::IN); } /** @@ -271,8 +255,7 @@ abstract class BaseAdminQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -281,18 +264,18 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @return ChildAdminQuery 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); + $this->addUsingAlias(AdminTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AdminPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -303,7 +286,7 @@ abstract class BaseAdminQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminPeer::ID, $id, $comparison); + return $this->addUsingAlias(AdminTableMap::ID, $id, $comparison); } /** @@ -319,7 +302,7 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @return ChildAdminQuery The current query, for fluid interface */ public function filterByFirstname($firstname = null, $comparison = null) { @@ -332,7 +315,7 @@ abstract class BaseAdminQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminPeer::FIRSTNAME, $firstname, $comparison); + return $this->addUsingAlias(AdminTableMap::FIRSTNAME, $firstname, $comparison); } /** @@ -348,7 +331,7 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @return ChildAdminQuery The current query, for fluid interface */ public function filterByLastname($lastname = null, $comparison = null) { @@ -361,7 +344,7 @@ abstract class BaseAdminQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminPeer::LASTNAME, $lastname, $comparison); + return $this->addUsingAlias(AdminTableMap::LASTNAME, $lastname, $comparison); } /** @@ -377,7 +360,7 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @return ChildAdminQuery The current query, for fluid interface */ public function filterByLogin($login = null, $comparison = null) { @@ -390,7 +373,7 @@ abstract class BaseAdminQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminPeer::LOGIN, $login, $comparison); + return $this->addUsingAlias(AdminTableMap::LOGIN, $login, $comparison); } /** @@ -406,7 +389,7 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @return ChildAdminQuery The current query, for fluid interface */ public function filterByPassword($password = null, $comparison = null) { @@ -419,7 +402,7 @@ abstract class BaseAdminQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminPeer::PASSWORD, $password, $comparison); + return $this->addUsingAlias(AdminTableMap::PASSWORD, $password, $comparison); } /** @@ -435,7 +418,7 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @return ChildAdminQuery The current query, for fluid interface */ public function filterByAlgo($algo = null, $comparison = null) { @@ -448,7 +431,7 @@ abstract class BaseAdminQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminPeer::ALGO, $algo, $comparison); + return $this->addUsingAlias(AdminTableMap::ALGO, $algo, $comparison); } /** @@ -464,7 +447,7 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @return ChildAdminQuery The current query, for fluid interface */ public function filterBySalt($salt = null, $comparison = null) { @@ -477,7 +460,7 @@ abstract class BaseAdminQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminPeer::SALT, $salt, $comparison); + return $this->addUsingAlias(AdminTableMap::SALT, $salt, $comparison); } /** @@ -498,18 +481,18 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @return ChildAdminQuery 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); + $this->addUsingAlias(AdminTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AdminPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -520,7 +503,7 @@ abstract class BaseAdminQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AdminTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -541,18 +524,18 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @return ChildAdminQuery 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); + $this->addUsingAlias(AdminTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AdminPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AdminTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -563,30 +546,29 @@ abstract class BaseAdminQuery extends ModelCriteria } } - return $this->addUsingAlias(AdminPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AdminTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related AdminGroup object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AdminGroup|ObjectCollection $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. + * @return ChildAdminQuery The current query, for fluid interface */ public function filterByAdminGroup($adminGroup, $comparison = null) { - if ($adminGroup instanceof AdminGroup) { + if ($adminGroup instanceof \Thelia\Model\AdminGroup) { return $this - ->addUsingAlias(AdminPeer::ID, $adminGroup->getAdminId(), $comparison); - } elseif ($adminGroup instanceof PropelObjectCollection) { + ->addUsingAlias(AdminTableMap::ID, $adminGroup->getAdminId(), $comparison); + } elseif ($adminGroup instanceof ObjectCollection) { return $this ->useAdminGroupQuery() ->filterByPrimaryKeys($adminGroup->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection'); + throw new PropelException('filterByAdminGroup() only accepts arguments of type \Thelia\Model\AdminGroup or Collection'); } } @@ -596,7 +578,7 @@ abstract class BaseAdminQuery extends ModelCriteria * @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 + * @return ChildAdminQuery The current query, for fluid interface */ public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -625,7 +607,7 @@ abstract class BaseAdminQuery extends ModelCriteria /** * Use the AdminGroup relation AdminGroup object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -644,10 +626,10 @@ abstract class BaseAdminQuery extends ModelCriteria * 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 + * @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 + * @return ChildAdminQuery The current query, for fluid interface */ public function filterByGroup($group, $comparison = Criteria::EQUAL) { @@ -660,19 +642,94 @@ abstract class BaseAdminQuery extends ModelCriteria /** * Exclude object from result * - * @param Admin $admin Object to remove from the list of results + * @param ChildAdmin $admin Object to remove from the list of results * - * @return AdminQuery The current query, for fluid interface + * @return ChildAdminQuery The current query, for fluid interface */ public function prune($admin = null) { if ($admin) { - $this->addUsingAlias(AdminPeer::ID, $admin->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(AdminTableMap::ID, $admin->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the admin table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AdminTableMap::clearInstancePool(); + AdminTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAdmin or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAdmin object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AdminTableMap::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(); + + + AdminTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AdminTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -680,31 +737,11 @@ abstract class BaseAdminQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AdminQuery The current query, for fluid interface + * @return ChildAdminQuery 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); + return $this->addUsingAlias(AdminTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -712,30 +749,51 @@ abstract class BaseAdminQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AdminQuery The current query, for fluid interface + * @return ChildAdminQuery 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); + return $this->addUsingAlias(AdminTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAdminQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AdminTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAdminQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AdminTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AdminQuery The current query, for fluid interface + * @return ChildAdminQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AdminPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AdminTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AdminQuery The current query, for fluid interface + * @return ChildAdminQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AdminPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AdminTableMap::CREATED_AT); } -} + +} // AdminQuery diff --git a/core/lib/Thelia/Model/Base/Area.php b/core/lib/Thelia/Model/Base/Area.php new file mode 100644 index 000000000..fbd3199f4 --- /dev/null +++ b/core/lib/Thelia/Model/Base/Area.php @@ -0,0 +1,1904 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Area instance. If + * obj is an instance of Area, delegates to + * equals(Area). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Area The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Area The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 [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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\Area The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AreaTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [name] column. + * + * @param string $v new value + * @return \Thelia\Model\Area The current object (for fluent API support) + */ + public function setName($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->name !== $v) { + $this->name = $v; + $this->modifiedColumns[] = AreaTableMap::NAME; + } + + + return $this; + } // setName() + + /** + * Set the value of [unit] column. + * + * @param double $v new value + * @return \Thelia\Model\Area The current object (for fluent API support) + */ + public function setUnit($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->unit !== $v) { + $this->unit = $v; + $this->modifiedColumns[] = AreaTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AreaTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AreaTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AreaTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AreaTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; + $this->name = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaTableMap::translateFieldName('Unit', TableMap::TYPE_PHPNAME, $indexType)]; + $this->unit = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AreaTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AreaTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = AreaTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\Area object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(AreaTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildAreaQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->collCountries = null; + + $this->collDelivzones = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see Area::setDeleted() + * @see Area::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildAreaQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AreaTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AreaTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AreaTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + AreaTableMap::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 ConnectionInterface $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(ConnectionInterface $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->countriesScheduledForDeletion !== null) { + if (!$this->countriesScheduledForDeletion->isEmpty()) { + foreach ($this->countriesScheduledForDeletion as $country) { + // need to save related object because we set the relation to null + $country->save($con); + } + $this->countriesScheduledForDeletion = null; + } + } + + if ($this->collCountries !== null) { + foreach ($this->collCountries 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = AreaTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AreaTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AreaTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(AreaTableMap::NAME)) { + $modifiedColumns[':p' . $index++] = 'NAME'; + } + if ($this->isColumnModified(AreaTableMap::UNIT)) { + $modifiedColumns[':p' . $index++] = 'UNIT'; + } + if ($this->isColumnModified(AreaTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(AreaTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = AreaTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Area'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Area'][$this->getPrimaryKey()] = true; + $keys = AreaTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getName(), + $keys[2] => $this->getUnit(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collCountries) { + $result['Countries'] = $this->collCountries->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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = AreaTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = AreaTableMap::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(AreaTableMap::DATABASE_NAME); + + if ($this->isColumnModified(AreaTableMap::ID)) $criteria->add(AreaTableMap::ID, $this->id); + if ($this->isColumnModified(AreaTableMap::NAME)) $criteria->add(AreaTableMap::NAME, $this->name); + if ($this->isColumnModified(AreaTableMap::UNIT)) $criteria->add(AreaTableMap::UNIT, $this->unit); + if ($this->isColumnModified(AreaTableMap::CREATED_AT)) $criteria->add(AreaTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AreaTableMap::UPDATED_AT)) $criteria->add(AreaTableMap::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(AreaTableMap::DATABASE_NAME); + $criteria->add(AreaTableMap::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 \Thelia\Model\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) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getCountries() 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)); + } + } + + } // 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 \Thelia\Model\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; + } + + + /** + * 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) { + return $this->initCountries(); + } + if ('Delivzone' == $relationName) { + return $this->initDelivzones(); + } + } + + /** + * Clears out the collCountries collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addCountries() + */ + public function clearCountries() + { + $this->collCountries = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collCountries collection loaded partially. + */ + public function resetPartialCountries($v = true) + { + $this->collCountriesPartial = $v; + } + + /** + * Initializes the collCountries collection. + * + * By default this just sets the collCountries collection to an empty array (like clearcollCountries()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initCountries($overrideExisting = true) + { + if (null !== $this->collCountries && !$overrideExisting) { + return; + } + $this->collCountries = new ObjectCollection(); + $this->collCountries->setModel('\Thelia\Model\Country'); + } + + /** + * Gets an array of ChildCountry objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildArea is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCountry[] List of ChildCountry objects + * @throws PropelException + */ + public function getCountries($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collCountriesPartial && !$this->isNew(); + if (null === $this->collCountries || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCountries) { + // return empty collection + $this->initCountries(); + } else { + $collCountries = ChildCountryQuery::create(null, $criteria) + ->filterByArea($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collCountriesPartial && count($collCountries)) { + $this->initCountries(false); + + foreach ($collCountries as $obj) { + if (false == $this->collCountries->contains($obj)) { + $this->collCountries->append($obj); + } + } + + $this->collCountriesPartial = true; + } + + $collCountries->getInternalIterator()->rewind(); + + return $collCountries; + } + + if ($partial && $this->collCountries) { + foreach ($this->collCountries as $obj) { + if ($obj->isNew()) { + $collCountries[] = $obj; + } + } + } + + $this->collCountries = $collCountries; + $this->collCountriesPartial = false; + } + } + + return $this->collCountries; + } + + /** + * 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 Collection $countries A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildArea The current object (for fluent API support) + */ + public function setCountries(Collection $countries, ConnectionInterface $con = null) + { + $countriesToDelete = $this->getCountries(new Criteria(), $con)->diff($countries); + + + $this->countriesScheduledForDeletion = $countriesToDelete; + + foreach ($countriesToDelete as $countryRemoved) { + $countryRemoved->setArea(null); + } + + $this->collCountries = null; + foreach ($countries as $country) { + $this->addCountry($country); + } + + $this->collCountries = $countries; + $this->collCountriesPartial = false; + + return $this; + } + + /** + * Returns the number of related Country objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related Country objects. + * @throws PropelException + */ + public function countCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collCountriesPartial && !$this->isNew(); + if (null === $this->collCountries || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCountries) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getCountries()); + } + + $query = ChildCountryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByArea($this) + ->count($con); + } + + return count($this->collCountries); + } + + /** + * Method called to associate a ChildCountry object to this object + * through the ChildCountry foreign key attribute. + * + * @param ChildCountry $l ChildCountry + * @return \Thelia\Model\Area The current object (for fluent API support) + */ + public function addCountry(ChildCountry $l) + { + if ($this->collCountries === null) { + $this->initCountries(); + $this->collCountriesPartial = true; + } + + if (!in_array($l, $this->collCountries->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->collCountries[]= $country; + $country->setArea($this); + } + + /** + * @param Country $country The country object to remove. + * @return ChildArea The current object (for fluent API support) + */ + public function removeCountry($country) + { + if ($this->getCountries()->contains($country)) { + $this->collCountries->remove($this->collCountries->search($country)); + if (null === $this->countriesScheduledForDeletion) { + $this->countriesScheduledForDeletion = clone $this->collCountries; + $this->countriesScheduledForDeletion->clear(); + } + $this->countriesScheduledForDeletion[]= $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 void + * @see addDelivzones() + */ + public function clearDelivzones() + { + $this->collDelivzones = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collDelivzones collection loaded partially. + */ + 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 ObjectCollection(); + $this->collDelivzones->setModel('\Thelia\Model\Delivzone'); + } + + /** + * Gets an array of ChildDelivzone objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildArea is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildDelivzone[] List of ChildDelivzone objects + * @throws PropelException + */ + public function getDelivzones($criteria = null, ConnectionInterface $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 = ChildDelivzoneQuery::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 Collection $delivzones A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildArea The current object (for fluent API support) + */ + public function setDelivzones(Collection $delivzones, ConnectionInterface $con = null) + { + $delivzonesToDelete = $this->getDelivzones(new Criteria(), $con)->diff($delivzones); + + + $this->delivzonesScheduledForDeletion = $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 ConnectionInterface $con + * @return int Count of related Delivzone objects. + * @throws PropelException + */ + public function countDelivzones(Criteria $criteria = null, $distinct = false, ConnectionInterface $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 = ChildDelivzoneQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByArea($this) + ->count($con); + } + + return count($this->collDelivzones); + } + + /** + * Method called to associate a ChildDelivzone object to this object + * through the ChildDelivzone foreign key attribute. + * + * @param ChildDelivzone $l ChildDelivzone + * @return \Thelia\Model\Area The current object (for fluent API support) + */ + public function addDelivzone(ChildDelivzone $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 ChildArea 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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collCountries) { + foreach ($this->collCountries as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collDelivzones) { + foreach ($this->collDelivzones as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + if ($this->collCountries instanceof Collection) { + $this->collCountries->clearIterator(); + } + $this->collCountries = null; + if ($this->collDelivzones instanceof Collection) { + $this->collDelivzones->clearIterator(); + } + $this->collDelivzones = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AreaTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildArea The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AreaTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseAreaQuery.php b/core/lib/Thelia/Model/Base/AreaQuery.php old mode 100755 new mode 100644 similarity index 54% rename from core/lib/Thelia/Model/om/BaseAreaQuery.php rename to core/lib/Thelia/Model/Base/AreaQuery.php index 3feaaca2f..f583a30dd --- a/core/lib/Thelia/Model/om/BaseAreaQuery.php +++ b/core/lib/Thelia/Model/Base/AreaQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -111,21 +110,21 @@ abstract class BaseAreaQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Area|Area[]|mixed the result, formatted by the current formatter + * @return ChildArea|array|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 + if ((null !== ($obj = AreaTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AreaTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -137,46 +136,31 @@ abstract class BaseAreaQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Area A model object, or null if the key is not found - * @throws PropelException + * @return ChildArea A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `name`, `unit`, `created_at`, `updated_at` FROM `area` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Area(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildArea(); $obj->hydrate($row); - AreaPeer::addInstanceToPool($obj, (string) $key); + AreaTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -187,19 +171,19 @@ abstract class BaseAreaQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Area|Area[]|mixed the result, formatted by the current formatter + * @return ChildArea|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -208,22 +192,22 @@ abstract class BaseAreaQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Area[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -231,12 +215,12 @@ abstract class BaseAreaQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AreaQuery The current query, for fluid interface + * @return ChildAreaQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(AreaPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AreaTableMap::ID, $key, Criteria::EQUAL); } /** @@ -244,12 +228,12 @@ abstract class BaseAreaQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AreaQuery The current query, for fluid interface + * @return ChildAreaQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(AreaPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AreaTableMap::ID, $keys, Criteria::IN); } /** @@ -259,8 +243,7 @@ abstract class BaseAreaQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -269,18 +252,18 @@ abstract class BaseAreaQuery extends ModelCriteria * 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 + * @return ChildAreaQuery 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); + $this->addUsingAlias(AreaTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AreaPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -291,7 +274,7 @@ abstract class BaseAreaQuery extends ModelCriteria } } - return $this->addUsingAlias(AreaPeer::ID, $id, $comparison); + return $this->addUsingAlias(AreaTableMap::ID, $id, $comparison); } /** @@ -307,7 +290,7 @@ abstract class BaseAreaQuery extends ModelCriteria * 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 + * @return ChildAreaQuery The current query, for fluid interface */ public function filterByName($name = null, $comparison = null) { @@ -320,7 +303,7 @@ abstract class BaseAreaQuery extends ModelCriteria } } - return $this->addUsingAlias(AreaPeer::NAME, $name, $comparison); + return $this->addUsingAlias(AreaTableMap::NAME, $name, $comparison); } /** @@ -330,8 +313,7 @@ abstract class BaseAreaQuery extends ModelCriteria * * $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 + * $query->filterByUnit(array('min' => 12)); // WHERE unit > 12 * * * @param mixed $unit The value to use as filter. @@ -340,18 +322,18 @@ abstract class BaseAreaQuery extends ModelCriteria * 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 + * @return ChildAreaQuery 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); + $this->addUsingAlias(AreaTableMap::UNIT, $unit['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($unit['max'])) { - $this->addUsingAlias(AreaPeer::UNIT, $unit['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaTableMap::UNIT, $unit['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -362,7 +344,7 @@ abstract class BaseAreaQuery extends ModelCriteria } } - return $this->addUsingAlias(AreaPeer::UNIT, $unit, $comparison); + return $this->addUsingAlias(AreaTableMap::UNIT, $unit, $comparison); } /** @@ -383,18 +365,18 @@ abstract class BaseAreaQuery extends ModelCriteria * 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 + * @return ChildAreaQuery 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); + $this->addUsingAlias(AreaTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -405,7 +387,7 @@ abstract class BaseAreaQuery extends ModelCriteria } } - return $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AreaTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -426,18 +408,18 @@ abstract class BaseAreaQuery extends ModelCriteria * 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 + * @return ChildAreaQuery 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); + $this->addUsingAlias(AreaTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -448,30 +430,29 @@ abstract class BaseAreaQuery extends ModelCriteria } } - return $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AreaTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Country object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Country|ObjectCollection $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. + * @return ChildAreaQuery The current query, for fluid interface */ public function filterByCountry($country, $comparison = null) { - if ($country instanceof Country) { + if ($country instanceof \Thelia\Model\Country) { return $this - ->addUsingAlias(AreaPeer::ID, $country->getAreaId(), $comparison); - } elseif ($country instanceof PropelObjectCollection) { + ->addUsingAlias(AreaTableMap::ID, $country->getAreaId(), $comparison); + } elseif ($country instanceof ObjectCollection) { return $this ->useCountryQuery() ->filterByPrimaryKeys($country->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection'); + throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection'); } } @@ -481,7 +462,7 @@ abstract class BaseAreaQuery extends ModelCriteria * @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 + * @return ChildAreaQuery The current query, for fluid interface */ public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -510,7 +491,7 @@ abstract class BaseAreaQuery extends ModelCriteria /** * Use the Country relation Country object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -526,26 +507,25 @@ abstract class BaseAreaQuery extends ModelCriteria } /** - * Filter the query by a related Delivzone object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Delivzone|ObjectCollection $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. + * @return ChildAreaQuery The current query, for fluid interface */ public function filterByDelivzone($delivzone, $comparison = null) { - if ($delivzone instanceof Delivzone) { + if ($delivzone instanceof \Thelia\Model\Delivzone) { return $this - ->addUsingAlias(AreaPeer::ID, $delivzone->getAreaId(), $comparison); - } elseif ($delivzone instanceof PropelObjectCollection) { + ->addUsingAlias(AreaTableMap::ID, $delivzone->getAreaId(), $comparison); + } elseif ($delivzone instanceof ObjectCollection) { return $this ->useDelivzoneQuery() ->filterByPrimaryKeys($delivzone->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDelivzone() only accepts arguments of type Delivzone or PropelCollection'); + throw new PropelException('filterByDelivzone() only accepts arguments of type \Thelia\Model\Delivzone or Collection'); } } @@ -555,7 +535,7 @@ abstract class BaseAreaQuery extends ModelCriteria * @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 + * @return ChildAreaQuery The current query, for fluid interface */ public function joinDelivzone($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -584,7 +564,7 @@ abstract class BaseAreaQuery extends ModelCriteria /** * Use the Delivzone relation Delivzone object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -602,19 +582,94 @@ abstract class BaseAreaQuery extends ModelCriteria /** * Exclude object from result * - * @param Area $area Object to remove from the list of results + * @param ChildArea $area Object to remove from the list of results * - * @return AreaQuery The current query, for fluid interface + * @return ChildAreaQuery The current query, for fluid interface */ public function prune($area = null) { if ($area) { - $this->addUsingAlias(AreaPeer::ID, $area->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(AreaTableMap::ID, $area->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the area table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AreaTableMap::clearInstancePool(); + AreaTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildArea or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildArea object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AreaTableMap::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(); + + + AreaTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AreaTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -622,31 +677,11 @@ abstract class BaseAreaQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AreaQuery The current query, for fluid interface + * @return ChildAreaQuery 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); + return $this->addUsingAlias(AreaTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -654,30 +689,51 @@ abstract class BaseAreaQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AreaQuery The current query, for fluid interface + * @return ChildAreaQuery 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); + return $this->addUsingAlias(AreaTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAreaQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AreaTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAreaQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AreaTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AreaQuery The current query, for fluid interface + * @return ChildAreaQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AreaPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AreaTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AreaQuery The current query, for fluid interface + * @return ChildAreaQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AreaPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AreaTableMap::CREATED_AT); } -} + +} // AreaQuery diff --git a/core/lib/Thelia/Model/om/BaseAttribute.php b/core/lib/Thelia/Model/Base/Attribute.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseAttribute.php rename to core/lib/Thelia/Model/Base/Attribute.php index 9deb6fe5e..481398b95 --- a/core/lib/Thelia/Model/om/BaseAttribute.php +++ b/core/lib/Thelia/Model/Base/Attribute.php @@ -1,61 +1,69 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Attribute instance. If + * obj is an instance of Attribute, delegates to + * equals(Attribute). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Attribute The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Attribute The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -198,97 +450,57 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Attribute The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = AttributePeer::ID; + $this->modifiedColumns[] = AttributeTableMap::ID; } @@ -298,18 +510,18 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return Attribute The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Attribute The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = AttributePeer::POSITION; + $this->modifiedColumns[] = AttributeTableMap::POSITION; } @@ -319,19 +531,17 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Attribute The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AttributeTableMap::CREATED_AT; } } // if either are not null @@ -342,19 +552,17 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Attribute The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AttributeTableMap::UPDATED_AT; } } // if either are not null @@ -372,7 +580,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -384,20 +592,38 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -405,11 +631,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = AttributePeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 4; // 4 = AttributeTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Attribute object", $e); + throw new PropelException("Error populating \Thelia\Model\Attribute object", 0, $e); } } @@ -428,7 +654,6 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -436,12 +661,12 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -452,19 +677,19 @@ abstract class BaseAttribute extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AttributeTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildAttributeQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -472,37 +697,36 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->collAttributeCombinations = null; - $this->collAttributeCategorys = null; + $this->collAttributeCategories = null; $this->collAttributeI18ns = null; - $this->collCategorys = null; + $this->collCategories = null; } // if (deep) } /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Attribute::setDeleted() + * @see Attribute::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = AttributeQuery::create() + $deleteQuery = ChildAttributeQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -527,20 +751,19 @@ abstract class BaseAttribute extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -550,16 +773,16 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(AttributePeer::CREATED_AT)) { + if (!$this->isColumnModified(AttributeTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(AttributePeer::UPDATED_AT)) { + if (!$this->isColumnModified(AttributeTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AttributePeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(AttributeTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -571,7 +794,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - AttributePeer::addInstanceToPool($this); + AttributeTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -590,12 +813,12 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -612,26 +835,27 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->resetModified(); } - if ($this->categorysScheduledForDeletion !== null) { - if (!$this->categorysScheduledForDeletion->isEmpty()) { + if ($this->categoriesScheduledForDeletion !== null) { + if (!$this->categoriesScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->categorysScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + $pk = $this->getPrimaryKey(); + foreach ($this->categoriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($remotePk, $pk); } + AttributeCategoryQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); - $this->categorysScheduledForDeletion = null; + $this->categoriesScheduledForDeletion = null; } - foreach ($this->getCategorys() as $category) { + foreach ($this->getCategories() as $category) { if ($category->isModified()) { $category->save($con); } } - } elseif ($this->collCategorys) { - foreach ($this->collCategorys as $category) { + } elseif ($this->collCategories) { + foreach ($this->collCategories as $category) { if ($category->isModified()) { $category->save($con); } @@ -640,15 +864,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($this->attributeAvsScheduledForDeletion !== null) { if (!$this->attributeAvsScheduledForDeletion->isEmpty()) { - AttributeAvQuery::create() + \Thelia\Model\AttributeAvQuery::create() ->filterByPrimaryKeys($this->attributeAvsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->attributeAvsScheduledForDeletion = null; } } - if ($this->collAttributeAvs !== null) { - foreach ($this->collAttributeAvs as $referrerFK) { + if ($this->collAttributeAvs !== null) { + foreach ($this->collAttributeAvs as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -657,32 +881,32 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($this->attributeCombinationsScheduledForDeletion !== null) { if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) { - AttributeCombinationQuery::create() + \Thelia\Model\AttributeCombinationQuery::create() ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->attributeCombinationsScheduledForDeletion = null; } } - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { + 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)) + if ($this->attributeCategoriesScheduledForDeletion !== null) { + if (!$this->attributeCategoriesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AttributeCategoryQuery::create() + ->filterByPrimaryKeys($this->attributeCategoriesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->attributeCategorysScheduledForDeletion = null; + $this->attributeCategoriesScheduledForDeletion = null; } } - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { + if ($this->collAttributeCategories !== null) { + foreach ($this->collAttributeCategories as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -691,15 +915,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent if ($this->attributeI18nsScheduledForDeletion !== null) { if (!$this->attributeI18nsScheduledForDeletion->isEmpty()) { - AttributeI18nQuery::create() + \Thelia\Model\AttributeI18nQuery::create() ->filterByPrimaryKeys($this->attributeI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->attributeI18nsScheduledForDeletion = null; } } - if ($this->collAttributeI18ns !== null) { - foreach ($this->collAttributeI18ns as $referrerFK) { + if ($this->collAttributeI18ns !== null) { + foreach ($this->collAttributeI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -716,37 +940,37 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = AttributePeer::ID; + $this->modifiedColumns[] = AttributeTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributePeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(AttributeTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(AttributePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(AttributeTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(AttributePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(AttributeTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(AttributePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(AttributeTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `attribute` (%s) VALUES (%s)', + 'INSERT INTO attribute (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -755,30 +979,30 @@ abstract class BaseAttribute extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -788,136 +1012,32 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = AttributePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = AttributeTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -927,7 +1047,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -957,28 +1077,34 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = AttributeTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getPosition(), $keys[2] => $this->getCreatedAt(), $keys[3] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collAttributeAvs) { $result['AttributeAvs'] = $this->collAttributeAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -986,8 +1112,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent 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->collAttributeCategories) { + $result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collAttributeI18ns) { $result['AttributeI18ns'] = $this->collAttributeI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1000,27 +1126,27 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = AttributePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = AttributeTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1050,17 +1176,17 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = AttributePeer::getFieldNames($keyType); + $keys = AttributeTableMap::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]]); @@ -1075,12 +1201,12 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(AttributePeer::DATABASE_NAME); + $criteria = new Criteria(AttributeTableMap::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); + if ($this->isColumnModified(AttributeTableMap::ID)) $criteria->add(AttributeTableMap::ID, $this->id); + if ($this->isColumnModified(AttributeTableMap::POSITION)) $criteria->add(AttributeTableMap::POSITION, $this->position); + if ($this->isColumnModified(AttributeTableMap::CREATED_AT)) $criteria->add(AttributeTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AttributeTableMap::UPDATED_AT)) $criteria->add(AttributeTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1095,15 +1221,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(AttributePeer::DATABASE_NAME); - $criteria->add(AttributePeer::ID, $this->id); + $criteria = new Criteria(AttributeTableMap::DATABASE_NAME); + $criteria->add(AttributeTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1113,7 +1239,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1137,9 +1263,9 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1148,12 +1274,10 @@ abstract class BaseAttribute extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1167,7 +1291,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent } } - foreach ($this->getAttributeCategorys() as $relObj) { + foreach ($this->getAttributeCategories() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addAttributeCategory($relObj->copy($deepCopy)); } @@ -1179,8 +1303,6 @@ abstract class BaseAttribute extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1197,8 +1319,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Attribute Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1211,46 +1333,28 @@ abstract class BaseAttribute extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('AttributeAv' == $relationName) { - $this->initAttributeAvs(); + return $this->initAttributeAvs(); } if ('AttributeCombination' == $relationName) { - $this->initAttributeCombinations(); + return $this->initAttributeCombinations(); } if ('AttributeCategory' == $relationName) { - $this->initAttributeCategorys(); + return $this->initAttributeCategories(); } if ('AttributeI18n' == $relationName) { - $this->initAttributeI18ns(); + return $this->initAttributeI18ns(); } } @@ -1260,21 +1364,16 @@ abstract class BaseAttribute extends BaseObject implements Persistent * This 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) + * @return void * @see addAttributeAvs() */ public function clearAttributeAvs() { - $this->collAttributeAvs = null; // important to set this to null since that means it is uninitialized - $this->collAttributeAvsPartial = null; - - return $this; + $this->collAttributeAvs = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collAttributeAvs collection loaded partially - * - * @return void + * Reset is the collAttributeAvs collection loaded partially. */ public function resetPartialAttributeAvs($v = true) { @@ -1288,7 +1387,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1298,25 +1397,25 @@ abstract class BaseAttribute extends BaseObject implements Persistent if (null !== $this->collAttributeAvs && !$overrideExisting) { return; } - $this->collAttributeAvs = new PropelObjectCollection(); - $this->collAttributeAvs->setModel('AttributeAv'); + $this->collAttributeAvs = new ObjectCollection(); + $this->collAttributeAvs->setModel('\Thelia\Model\AttributeAv'); } /** - * Gets an array of AttributeAv objects which contain a foreign key that references this object. + * Gets an array of ChildAttributeAv objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildAttribute is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAttributeAv[] List of ChildAttributeAv objects * @throws PropelException */ - public function getAttributeAvs($criteria = null, PropelPDO $con = null) + public function getAttributeAvs($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeAvsPartial && !$this->isNew(); if (null === $this->collAttributeAvs || null !== $criteria || $partial) { @@ -1324,29 +1423,31 @@ abstract class BaseAttribute extends BaseObject implements Persistent // return empty collection $this->initAttributeAvs(); } else { - $collAttributeAvs = AttributeAvQuery::create(null, $criteria) + $collAttributeAvs = ChildAttributeAvQuery::create(null, $criteria) ->filterByAttribute($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collAttributeAvsPartial && count($collAttributeAvs)) { - $this->initAttributeAvs(false); + $this->initAttributeAvs(false); - foreach($collAttributeAvs as $obj) { - if (false == $this->collAttributeAvs->contains($obj)) { - $this->collAttributeAvs->append($obj); + foreach ($collAttributeAvs as $obj) { + if (false == $this->collAttributeAvs->contains($obj)) { + $this->collAttributeAvs->append($obj); + } } - } - $this->collAttributeAvsPartial = true; + $this->collAttributeAvsPartial = true; } $collAttributeAvs->getInternalIterator()->rewind(); + return $collAttributeAvs; } - if($partial && $this->collAttributeAvs) { - foreach($this->collAttributeAvs as $obj) { - if($obj->isNew()) { + if ($partial && $this->collAttributeAvs) { + foreach ($this->collAttributeAvs as $obj) { + if ($obj->isNew()) { $collAttributeAvs[] = $obj; } } @@ -1366,15 +1467,16 @@ abstract class BaseAttribute extends BaseObject implements Persistent * It will 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) + * @param Collection $attributeAvs A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildAttribute The current object (for fluent API support) */ - public function setAttributeAvs(PropelCollection $attributeAvs, PropelPDO $con = null) + public function setAttributeAvs(Collection $attributeAvs, ConnectionInterface $con = null) { $attributeAvsToDelete = $this->getAttributeAvs(new Criteria(), $con)->diff($attributeAvs); - $this->attributeAvsScheduledForDeletion = unserialize(serialize($attributeAvsToDelete)); + + $this->attributeAvsScheduledForDeletion = $attributeAvsToDelete; foreach ($attributeAvsToDelete as $attributeAvRemoved) { $attributeAvRemoved->setAttribute(null); @@ -1394,13 +1496,13 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Returns the number of related AttributeAv objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AttributeAv objects. * @throws PropelException */ - public function countAttributeAvs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributeAvs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeAvsPartial && !$this->isNew(); if (null === $this->collAttributeAvs || null !== $criteria || $partial) { @@ -1408,10 +1510,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getAttributeAvs()); } - $query = AttributeAvQuery::create(null, $criteria); + + $query = ChildAttributeAvQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1425,18 +1528,19 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * Method called to associate a AttributeAv object to this object - * through the AttributeAv foreign key attribute. + * Method called to associate a ChildAttributeAv object to this object + * through the ChildAttributeAv foreign key attribute. * - * @param AttributeAv $l AttributeAv - * @return Attribute The current object (for fluent API support) + * @param ChildAttributeAv $l ChildAttributeAv + * @return \Thelia\Model\Attribute The current object (for fluent API support) */ - public function addAttributeAv(AttributeAv $l) + public function addAttributeAv(ChildAttributeAv $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); } @@ -1445,7 +1549,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * @param AttributeAv $attributeAv The attributeAv object to add. + * @param AttributeAv $attributeAv The attributeAv object to add. */ protected function doAddAttributeAv($attributeAv) { @@ -1454,8 +1558,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * @param AttributeAv $attributeAv The attributeAv object to remove. - * @return Attribute The current object (for fluent API support) + * @param AttributeAv $attributeAv The attributeAv object to remove. + * @return ChildAttribute The current object (for fluent API support) */ public function removeAttributeAv($attributeAv) { @@ -1478,21 +1582,16 @@ abstract class BaseAttribute extends BaseObject implements Persistent * This 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) + * @return void * @see addAttributeCombinations() */ public function clearAttributeCombinations() { - $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized - $this->collAttributeCombinationsPartial = null; - - return $this; + $this->collAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collAttributeCombinations collection loaded partially - * - * @return void + * Reset is the collAttributeCombinations collection loaded partially. */ public function resetPartialAttributeCombinations($v = true) { @@ -1506,7 +1605,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1516,25 +1615,25 @@ abstract class BaseAttribute extends BaseObject implements Persistent if (null !== $this->collAttributeCombinations && !$overrideExisting) { return; } - $this->collAttributeCombinations = new PropelObjectCollection(); - $this->collAttributeCombinations->setModel('AttributeCombination'); + $this->collAttributeCombinations = new ObjectCollection(); + $this->collAttributeCombinations->setModel('\Thelia\Model\AttributeCombination'); } /** - * Gets an array of AttributeCombination objects which contain a foreign key that references this object. + * Gets an array of ChildAttributeCombination objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildAttribute is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects * @throws PropelException */ - public function getAttributeCombinations($criteria = null, PropelPDO $con = null) + public function getAttributeCombinations($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { @@ -1542,29 +1641,31 @@ abstract class BaseAttribute extends BaseObject implements Persistent // return empty collection $this->initAttributeCombinations(); } else { - $collAttributeCombinations = AttributeCombinationQuery::create(null, $criteria) + $collAttributeCombinations = ChildAttributeCombinationQuery::create(null, $criteria) ->filterByAttribute($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) { - $this->initAttributeCombinations(false); + $this->initAttributeCombinations(false); - foreach($collAttributeCombinations as $obj) { - if (false == $this->collAttributeCombinations->contains($obj)) { - $this->collAttributeCombinations->append($obj); + foreach ($collAttributeCombinations as $obj) { + if (false == $this->collAttributeCombinations->contains($obj)) { + $this->collAttributeCombinations->append($obj); + } } - } - $this->collAttributeCombinationsPartial = true; + $this->collAttributeCombinationsPartial = true; } $collAttributeCombinations->getInternalIterator()->rewind(); + return $collAttributeCombinations; } - if($partial && $this->collAttributeCombinations) { - foreach($this->collAttributeCombinations as $obj) { - if($obj->isNew()) { + if ($partial && $this->collAttributeCombinations) { + foreach ($this->collAttributeCombinations as $obj) { + if ($obj->isNew()) { $collAttributeCombinations[] = $obj; } } @@ -1584,15 +1685,19 @@ abstract class BaseAttribute extends BaseObject implements Persistent * It will 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) + * @param Collection $attributeCombinations A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildAttribute The current object (for fluent API support) */ - public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null) + public function setAttributeCombinations(Collection $attributeCombinations, ConnectionInterface $con = null) { $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - $this->attributeCombinationsScheduledForDeletion = unserialize(serialize($attributeCombinationsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->attributeCombinationsScheduledForDeletion = clone $attributeCombinationsToDelete; foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { $attributeCombinationRemoved->setAttribute(null); @@ -1612,13 +1717,13 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Returns the number of related AttributeCombination objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AttributeCombination objects. * @throws PropelException */ - public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { @@ -1626,10 +1731,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getAttributeCombinations()); } - $query = AttributeCombinationQuery::create(null, $criteria); + + $query = ChildAttributeCombinationQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1643,18 +1749,19 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * Method called to associate a AttributeCombination object to this object - * through the AttributeCombination foreign key attribute. + * Method called to associate a ChildAttributeCombination object to this object + * through the ChildAttributeCombination foreign key attribute. * - * @param AttributeCombination $l AttributeCombination - * @return Attribute The current object (for fluent API support) + * @param ChildAttributeCombination $l ChildAttributeCombination + * @return \Thelia\Model\Attribute The current object (for fluent API support) */ - public function addAttributeCombination(AttributeCombination $l) + public function addAttributeCombination(ChildAttributeCombination $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); } @@ -1663,7 +1770,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * @param AttributeCombination $attributeCombination The attributeCombination object to add. + * @param AttributeCombination $attributeCombination The attributeCombination object to add. */ protected function doAddAttributeCombination($attributeCombination) { @@ -1672,8 +1779,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * @param AttributeCombination $attributeCombination The attributeCombination object to remove. - * @return Attribute The current object (for fluent API support) + * @param AttributeCombination $attributeCombination The attributeCombination object to remove. + * @return ChildAttribute The current object (for fluent API support) */ public function removeAttributeCombination($attributeCombination) { @@ -1702,15 +1809,15 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects */ - public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('AttributeAv', $join_behavior); + $query = ChildAttributeCombinationQuery::create(null, $criteria); + $query->joinWith('AttributeAv', $joinBehavior); return $this->getAttributeCombinations($query, $con); } @@ -1727,123 +1834,120 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects */ - public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Combination', $join_behavior); + $query = ChildAttributeCombinationQuery::create(null, $criteria); + $query->joinWith('Combination', $joinBehavior); return $this->getAttributeCombinations($query, $con); } /** - * Clears out the collAttributeCategorys collection + * Clears out the collAttributeCategories collection * * This 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 + * @see addAttributeCategories() */ - public function resetPartialAttributeCategorys($v = true) + public function clearAttributeCategories() { - $this->collAttributeCategorysPartial = $v; + $this->collAttributeCategories = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collAttributeCategorys collection. + * Reset is the collAttributeCategories collection loaded partially. + */ + public function resetPartialAttributeCategories($v = true) + { + $this->collAttributeCategoriesPartial = $v; + } + + /** + * Initializes the collAttributeCategories collection. * - * By default this just sets the collAttributeCategorys collection to an empty array (like clearcollAttributeCategorys()); + * By default this just sets the collAttributeCategories collection to an empty array (like clearcollAttributeCategories()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initAttributeCategories($overrideExisting = true) { - if (null !== $this->collAttributeCategorys && !$overrideExisting) { + if (null !== $this->collAttributeCategories && !$overrideExisting) { return; } - $this->collAttributeCategorys = new PropelObjectCollection(); - $this->collAttributeCategorys->setModel('AttributeCategory'); + $this->collAttributeCategories = new ObjectCollection(); + $this->collAttributeCategories->setModel('\Thelia\Model\AttributeCategory'); } /** - * Gets an array of AttributeCategory objects which contain a foreign key that references this object. + * Gets an array of ChildAttributeCategory objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildAttribute is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects * @throws PropelException */ - public function getAttributeCategorys($criteria = null, PropelPDO $con = null) + public function getAttributeCategories($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategorys) { + $partial = $this->collAttributeCategoriesPartial && !$this->isNew(); + if (null === $this->collAttributeCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeCategories) { // return empty collection - $this->initAttributeCategorys(); + $this->initAttributeCategories(); } else { - $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria) + $collAttributeCategories = ChildAttributeCategoryQuery::create(null, $criteria) ->filterByAttribute($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collAttributeCategorysPartial && count($collAttributeCategorys)) { - $this->initAttributeCategorys(false); + if (false !== $this->collAttributeCategoriesPartial && count($collAttributeCategories)) { + $this->initAttributeCategories(false); - foreach($collAttributeCategorys as $obj) { - if (false == $this->collAttributeCategorys->contains($obj)) { - $this->collAttributeCategorys->append($obj); + foreach ($collAttributeCategories as $obj) { + if (false == $this->collAttributeCategories->contains($obj)) { + $this->collAttributeCategories->append($obj); + } } - } - $this->collAttributeCategorysPartial = true; + $this->collAttributeCategoriesPartial = true; } - $collAttributeCategorys->getInternalIterator()->rewind(); - return $collAttributeCategorys; + $collAttributeCategories->getInternalIterator()->rewind(); + + return $collAttributeCategories; } - if($partial && $this->collAttributeCategorys) { - foreach($this->collAttributeCategorys as $obj) { - if($obj->isNew()) { - $collAttributeCategorys[] = $obj; + if ($partial && $this->collAttributeCategories) { + foreach ($this->collAttributeCategories as $obj) { + if ($obj->isNew()) { + $collAttributeCategories[] = $obj; } } } - $this->collAttributeCategorys = $collAttributeCategorys; - $this->collAttributeCategorysPartial = false; + $this->collAttributeCategories = $collAttributeCategories; + $this->collAttributeCategoriesPartial = false; } } - return $this->collAttributeCategorys; + return $this->collAttributeCategories; } /** @@ -1852,27 +1956,28 @@ abstract class BaseAttribute extends BaseObject implements Persistent * It will 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) + * @param Collection $attributeCategories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildAttribute The current object (for fluent API support) */ - public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null) + public function setAttributeCategories(Collection $attributeCategories, ConnectionInterface $con = null) { - $attributeCategorysToDelete = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); + $attributeCategoriesToDelete = $this->getAttributeCategories(new Criteria(), $con)->diff($attributeCategories); - $this->attributeCategorysScheduledForDeletion = unserialize(serialize($attributeCategorysToDelete)); - foreach ($attributeCategorysToDelete as $attributeCategoryRemoved) { + $this->attributeCategoriesScheduledForDeletion = $attributeCategoriesToDelete; + + foreach ($attributeCategoriesToDelete as $attributeCategoryRemoved) { $attributeCategoryRemoved->setAttribute(null); } - $this->collAttributeCategorys = null; - foreach ($attributeCategorys as $attributeCategory) { + $this->collAttributeCategories = null; + foreach ($attributeCategories as $attributeCategory) { $this->addAttributeCategory($attributeCategory); } - $this->collAttributeCategorys = $attributeCategorys; - $this->collAttributeCategorysPartial = false; + $this->collAttributeCategories = $attributeCategories; + $this->collAttributeCategoriesPartial = false; return $this; } @@ -1880,24 +1985,25 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Returns the number of related AttributeCategory objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AttributeCategory objects. * @throws PropelException */ - public function countAttributeCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributeCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategorys) { + $partial = $this->collAttributeCategoriesPartial && !$this->isNew(); + if (null === $this->collAttributeCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeCategories) { return 0; } - if($partial && !$criteria) { - return count($this->getAttributeCategorys()); + if ($partial && !$criteria) { + return count($this->getAttributeCategories()); } - $query = AttributeCategoryQuery::create(null, $criteria); + + $query = ChildAttributeCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1907,23 +2013,24 @@ abstract class BaseAttribute extends BaseObject implements Persistent ->count($con); } - return count($this->collAttributeCategorys); + return count($this->collAttributeCategories); } /** - * Method called to associate a AttributeCategory object to this object - * through the AttributeCategory foreign key attribute. + * Method called to associate a ChildAttributeCategory object to this object + * through the ChildAttributeCategory foreign key attribute. * - * @param AttributeCategory $l AttributeCategory - * @return Attribute The current object (for fluent API support) + * @param ChildAttributeCategory $l ChildAttributeCategory + * @return \Thelia\Model\Attribute The current object (for fluent API support) */ - public function addAttributeCategory(AttributeCategory $l) + public function addAttributeCategory(ChildAttributeCategory $l) { - if ($this->collAttributeCategorys === null) { - $this->initAttributeCategorys(); - $this->collAttributeCategorysPartial = true; + if ($this->collAttributeCategories === null) { + $this->initAttributeCategories(); + $this->collAttributeCategoriesPartial = true; } - if (!in_array($l, $this->collAttributeCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collAttributeCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeCategory($l); } @@ -1931,27 +2038,27 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * @param AttributeCategory $attributeCategory The attributeCategory object to add. + * @param AttributeCategory $attributeCategory The attributeCategory object to add. */ protected function doAddAttributeCategory($attributeCategory) { - $this->collAttributeCategorys[]= $attributeCategory; + $this->collAttributeCategories[]= $attributeCategory; $attributeCategory->setAttribute($this); } /** - * @param AttributeCategory $attributeCategory The attributeCategory object to remove. - * @return Attribute The current object (for fluent API support) + * @param AttributeCategory $attributeCategory The attributeCategory object to remove. + * @return ChildAttribute 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(); + if ($this->getAttributeCategories()->contains($attributeCategory)) { + $this->collAttributeCategories->remove($this->collAttributeCategories->search($attributeCategory)); + if (null === $this->attributeCategoriesScheduledForDeletion) { + $this->attributeCategoriesScheduledForDeletion = clone $this->collAttributeCategories; + $this->attributeCategoriesScheduledForDeletion->clear(); } - $this->attributeCategorysScheduledForDeletion[]= clone $attributeCategory; + $this->attributeCategoriesScheduledForDeletion[]= clone $attributeCategory; $attributeCategory->setAttribute(null); } @@ -1964,23 +2071,23 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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. + * been saved, it will retrieve related AttributeCategories from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects */ - public function getAttributeCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAttributeCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AttributeCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildAttributeCategoryQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); - return $this->getAttributeCategorys($query, $con); + return $this->getAttributeCategories($query, $con); } /** @@ -1989,21 +2096,16 @@ abstract class BaseAttribute extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collAttributeI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collAttributeI18ns collection loaded partially - * - * @return void + * Reset is the collAttributeI18ns collection loaded partially. */ public function resetPartialAttributeI18ns($v = true) { @@ -2017,7 +2119,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2027,25 +2129,25 @@ abstract class BaseAttribute extends BaseObject implements Persistent if (null !== $this->collAttributeI18ns && !$overrideExisting) { return; } - $this->collAttributeI18ns = new PropelObjectCollection(); - $this->collAttributeI18ns->setModel('AttributeI18n'); + $this->collAttributeI18ns = new ObjectCollection(); + $this->collAttributeI18ns->setModel('\Thelia\Model\AttributeI18n'); } /** - * Gets an array of AttributeI18n objects which contain a foreign key that references this object. + * Gets an array of ChildAttributeI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildAttribute is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAttributeI18n[] List of ChildAttributeI18n objects * @throws PropelException */ - public function getAttributeI18ns($criteria = null, PropelPDO $con = null) + public function getAttributeI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeI18nsPartial && !$this->isNew(); if (null === $this->collAttributeI18ns || null !== $criteria || $partial) { @@ -2053,29 +2155,31 @@ abstract class BaseAttribute extends BaseObject implements Persistent // return empty collection $this->initAttributeI18ns(); } else { - $collAttributeI18ns = AttributeI18nQuery::create(null, $criteria) + $collAttributeI18ns = ChildAttributeI18nQuery::create(null, $criteria) ->filterByAttribute($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collAttributeI18nsPartial && count($collAttributeI18ns)) { - $this->initAttributeI18ns(false); + $this->initAttributeI18ns(false); - foreach($collAttributeI18ns as $obj) { - if (false == $this->collAttributeI18ns->contains($obj)) { - $this->collAttributeI18ns->append($obj); + foreach ($collAttributeI18ns as $obj) { + if (false == $this->collAttributeI18ns->contains($obj)) { + $this->collAttributeI18ns->append($obj); + } } - } - $this->collAttributeI18nsPartial = true; + $this->collAttributeI18nsPartial = true; } $collAttributeI18ns->getInternalIterator()->rewind(); + return $collAttributeI18ns; } - if($partial && $this->collAttributeI18ns) { - foreach($this->collAttributeI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collAttributeI18ns) { + foreach ($this->collAttributeI18ns as $obj) { + if ($obj->isNew()) { $collAttributeI18ns[] = $obj; } } @@ -2095,15 +2199,19 @@ abstract class BaseAttribute extends BaseObject implements Persistent * It will 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) + * @param Collection $attributeI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildAttribute The current object (for fluent API support) */ - public function setAttributeI18ns(PropelCollection $attributeI18ns, PropelPDO $con = null) + public function setAttributeI18ns(Collection $attributeI18ns, ConnectionInterface $con = null) { $attributeI18nsToDelete = $this->getAttributeI18ns(new Criteria(), $con)->diff($attributeI18ns); - $this->attributeI18nsScheduledForDeletion = unserialize(serialize($attributeI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->attributeI18nsScheduledForDeletion = clone $attributeI18nsToDelete; foreach ($attributeI18nsToDelete as $attributeI18nRemoved) { $attributeI18nRemoved->setAttribute(null); @@ -2123,13 +2231,13 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Returns the number of related AttributeI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AttributeI18n objects. * @throws PropelException */ - public function countAttributeI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributeI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeI18nsPartial && !$this->isNew(); if (null === $this->collAttributeI18ns || null !== $criteria || $partial) { @@ -2137,10 +2245,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getAttributeI18ns()); } - $query = AttributeI18nQuery::create(null, $criteria); + + $query = ChildAttributeI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2154,13 +2263,13 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * Method called to associate a AttributeI18n object to this object - * through the AttributeI18n foreign key attribute. + * Method called to associate a ChildAttributeI18n object to this object + * through the ChildAttributeI18n foreign key attribute. * - * @param AttributeI18n $l AttributeI18n - * @return Attribute The current object (for fluent API support) + * @param ChildAttributeI18n $l ChildAttributeI18n + * @return \Thelia\Model\Attribute The current object (for fluent API support) */ - public function addAttributeI18n(AttributeI18n $l) + public function addAttributeI18n(ChildAttributeI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -2170,6 +2279,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent $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); } @@ -2178,7 +2288,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * @param AttributeI18n $attributeI18n The attributeI18n object to add. + * @param AttributeI18n $attributeI18n The attributeI18n object to add. */ protected function doAddAttributeI18n($attributeI18n) { @@ -2187,8 +2297,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * @param AttributeI18n $attributeI18n The attributeI18n object to remove. - * @return Attribute The current object (for fluent API support) + * @param AttributeI18n $attributeI18n The attributeI18n object to remove. + * @return ChildAttribute The current object (for fluent API support) */ public function removeAttributeI18n($attributeI18n) { @@ -2206,70 +2316,68 @@ abstract class BaseAttribute extends BaseObject implements Persistent } /** - * Clears out the collCategorys collection + * Clears out the collCategories collection * * This 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() + * @return void + * @see addCategories() */ - public function clearCategorys() + public function clearCategories() { - $this->collCategorys = null; // important to set this to null since that means it is uninitialized - $this->collCategorysPartial = null; - - return $this; + $this->collCategories = null; // important to set this to NULL since that means it is uninitialized + $this->collCategoriesPartial = null; } /** - * Initializes the collCategorys collection. + * Initializes the collCategories collection. * - * By default this just sets the collCategorys collection to an empty collection (like clearCategorys()); + * By default this just sets the collCategories collection to an empty collection (like clearCategories()); * however, you may wish to override this 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() + public function initCategories() { - $this->collCategorys = new PropelObjectCollection(); - $this->collCategorys->setModel('Category'); + $this->collCategories = new ObjectCollection(); + $this->collCategories->setModel('\Thelia\Model\Category'); } /** - * Gets a collection of Category objects related by a many-to-many relationship + * Gets a collection of ChildCategory 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 + * If this ChildAttribute 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Category[] List of Category objects + * @return ObjectCollection|ChildCategory[] List of ChildCategory objects */ - public function getCategorys($criteria = null, PropelPDO $con = null) + public function getCategories($criteria = null, ConnectionInterface $con = null) { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { + if (null === $this->collCategories || null !== $criteria) { + if ($this->isNew() && null === $this->collCategories) { // return empty collection - $this->initCategorys(); + $this->initCategories(); } else { - $collCategorys = CategoryQuery::create(null, $criteria) + $collCategories = ChildCategoryQuery::create(null, $criteria) ->filterByAttribute($this) ->find($con); if (null !== $criteria) { - return $collCategorys; + return $collCategories; } - $this->collCategorys = $collCategorys; + $this->collCategories = $collCategories; } } - return $this->collCategorys; + return $this->collCategories; } /** @@ -2278,45 +2386,45 @@ abstract class BaseAttribute extends BaseObject implements Persistent * It will 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) + * @param Collection $categories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildAttribute The current object (for fluent API support) */ - public function setCategorys(PropelCollection $categorys, PropelPDO $con = null) + public function setCategories(Collection $categories, ConnectionInterface $con = null) { - $this->clearCategorys(); - $currentCategorys = $this->getCategorys(); + $this->clearCategories(); + $currentCategories = $this->getCategories(); - $this->categorysScheduledForDeletion = $currentCategorys->diff($categorys); + $this->categoriesScheduledForDeletion = $currentCategories->diff($categories); - foreach ($categorys as $category) { - if (!$currentCategorys->contains($category)) { + foreach ($categories as $category) { + if (!$currentCategories->contains($category)) { $this->doAddCategory($category); } } - $this->collCategorys = $categorys; + $this->collCategories = $categories; return $this; } /** - * Gets the number of Category objects related by a many-to-many relationship + * Gets the number of ChildCategory 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Category objects + * @return int the number of related ChildCategory objects */ - public function countCategorys($criteria = null, $distinct = false, PropelPDO $con = null) + public function countCategories($criteria = null, $distinct = false, ConnectionInterface $con = null) { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { + if (null === $this->collCategories || null !== $criteria) { + if ($this->isNew() && null === $this->collCategories) { return 0; } else { - $query = CategoryQuery::create(null, $criteria); + $query = ChildCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2326,57 +2434,65 @@ abstract class BaseAttribute extends BaseObject implements Persistent ->count($con); } } else { - return count($this->collCategorys); + return count($this->collCategories); } } /** - * Associate a Category object to this object + * Associate a ChildCategory 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) + * @param ChildCategory $category The ChildAttributeCategory object to relate + * @return ChildAttribute The current object (for fluent API support) */ - public function addCategory(Category $category) + public function addCategory(ChildCategory $category) { - if ($this->collCategorys === null) { - $this->initCategorys(); + if ($this->collCategories === null) { + $this->initCategories(); } - if (!$this->collCategorys->contains($category)) { // only add it if the **same** object is not already associated - $this->doAddCategory($category); - $this->collCategorys[]= $category; + if (!$this->collCategories->contains($category)) { // only add it if the **same** object is not already associated + $this->doAddCategory($category); + $this->collCategories[] = $category; } return $this; } /** - * @param Category $category The category object to add. + * @param Category $category The category object to add. */ protected function doAddCategory($category) { - $attributeCategory = new AttributeCategory(); + $attributeCategory = new ChildAttributeCategory(); $attributeCategory->setCategory($category); $this->addAttributeCategory($attributeCategory); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$category->getAttributes()->contains($this)) { + $foreignCollection = $category->getAttributes(); + $foreignCollection[] = $this; + } } /** - * Remove a Category object to this object + * Remove a ChildCategory 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) + * @param ChildCategory $category The ChildAttributeCategory object to relate + * @return ChildAttribute The current object (for fluent API support) */ - public function removeCategory(Category $category) + public function removeCategory(ChildCategory $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(); + if ($this->getCategories()->contains($category)) { + $this->collCategories->remove($this->collCategories->search($category)); + + if (null === $this->categoriesScheduledForDeletion) { + $this->categoriesScheduledForDeletion = clone $this->collCategories; + $this->categoriesScheduledForDeletion->clear(); } - $this->categorysScheduledForDeletion[]= $category; + + $this->categoriesScheduledForDeletion[] = $category; } return $this; @@ -2392,8 +2508,6 @@ abstract class BaseAttribute extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2405,14 +2519,13 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collAttributeAvs) { foreach ($this->collAttributeAvs as $o) { $o->clearAllReferences($deep); @@ -2423,8 +2536,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->collAttributeCategorys) { - foreach ($this->collAttributeCategorys as $o) { + if ($this->collAttributeCategories) { + foreach ($this->collAttributeCategories as $o) { $o->clearAllReferences($deep); } } @@ -2433,59 +2546,47 @@ abstract class BaseAttribute extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->collCategorys) { - foreach ($this->collCategorys as $o) { + if ($this->collCategories) { + foreach ($this->collCategories as $o) { $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collAttributeAvs instanceof PropelCollection) { + if ($this->collAttributeAvs instanceof Collection) { $this->collAttributeAvs->clearIterator(); } $this->collAttributeAvs = null; - if ($this->collAttributeCombinations instanceof PropelCollection) { + if ($this->collAttributeCombinations instanceof Collection) { $this->collAttributeCombinations->clearIterator(); } $this->collAttributeCombinations = null; - if ($this->collAttributeCategorys instanceof PropelCollection) { - $this->collAttributeCategorys->clearIterator(); + if ($this->collAttributeCategories instanceof Collection) { + $this->collAttributeCategories->clearIterator(); } - $this->collAttributeCategorys = null; - if ($this->collAttributeI18ns instanceof PropelCollection) { + $this->collAttributeCategories = null; + if ($this->collAttributeI18ns instanceof Collection) { $this->collAttributeI18ns->clearIterator(); } $this->collAttributeI18ns = null; - if ($this->collCategorys instanceof PropelCollection) { - $this->collCategorys->clearIterator(); + if ($this->collCategories instanceof Collection) { + $this->collCategories->clearIterator(); } - $this->collCategorys = null; + $this->collCategories = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(AttributeTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2493,11 +2594,11 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * 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) + * @return ChildAttribute The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = AttributePeer::UPDATED_AT; + $this->modifiedColumns[] = AttributeTableMap::UPDATED_AT; return $this; } @@ -2509,9 +2610,9 @@ abstract class BaseAttribute extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Attribute The current object (for fluent API support) + * @return ChildAttribute The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2532,10 +2633,10 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return AttributeI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildAttributeI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeI18ns) { @@ -2548,10 +2649,10 @@ abstract class BaseAttribute extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new AttributeI18n(); + $translation = new ChildAttributeI18n(); $translation->setLocale($locale); } else { - $translation = AttributeI18nQuery::create() + $translation = ChildAttributeI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -2566,14 +2667,14 @@ abstract class BaseAttribute extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Attribute The current object (for fluent API support) + * @return ChildAttribute The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - AttributeI18nQuery::create() + ChildAttributeI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -2593,10 +2694,10 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return AttributeI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildAttributeI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -2605,7 +2706,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -2616,8 +2717,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\AttributeI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2629,7 +2730,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -2640,8 +2741,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\AttributeI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2653,7 +2754,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -2664,8 +2765,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\AttributeI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2677,7 +2778,7 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -2688,8 +2789,8 @@ abstract class BaseAttribute extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\AttributeI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -2697,4 +2798,122 @@ abstract class BaseAttribute extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseAttributeAv.php b/core/lib/Thelia/Model/Base/AttributeAv.php old mode 100755 new mode 100644 similarity index 56% rename from core/lib/Thelia/Model/om/BaseAttributeAv.php rename to core/lib/Thelia/Model/Base/AttributeAv.php index c6a4301a0..baed904dd --- a/core/lib/Thelia/Model/om/BaseAttributeAv.php +++ b/core/lib/Thelia/Model/Base/AttributeAv.php @@ -1,57 +1,65 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another AttributeAv instance. If + * obj is an instance of AttributeAv, delegates to + * equals(AttributeAv). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return AttributeAv The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return AttributeAv The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [attribute_id] column value. * - * @return int + * @return int */ public function getAttributeId() { + return $this->attribute_id; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -180,97 +433,57 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\AttributeAv The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = AttributeAvPeer::ID; + $this->modifiedColumns[] = AttributeAvTableMap::ID; } @@ -280,18 +493,18 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Set the value of [attribute_id] column. * - * @param int $v new value - * @return AttributeAv The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\AttributeAv The current object (for fluent API support) */ public function setAttributeId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->attribute_id !== $v) { $this->attribute_id = $v; - $this->modifiedColumns[] = AttributeAvPeer::ATTRIBUTE_ID; + $this->modifiedColumns[] = AttributeAvTableMap::ATTRIBUTE_ID; } if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) { @@ -305,18 +518,18 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return AttributeAv The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\AttributeAv The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = AttributeAvPeer::POSITION; + $this->modifiedColumns[] = AttributeAvTableMap::POSITION; } @@ -326,19 +539,17 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\AttributeAv The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AttributeAvTableMap::CREATED_AT; } } // if either are not null @@ -349,19 +560,17 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\AttributeAv The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AttributeAvTableMap::UPDATED_AT; } } // if either are not null @@ -379,7 +588,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -391,21 +600,41 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeAvTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeAvTableMap::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeAvTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeAvTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeAvTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -413,11 +642,11 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = AttributeAvPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 5; // 5 = AttributeAvTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating AttributeAv object", $e); + throw new PropelException("Error populating \Thelia\Model\AttributeAv object", 0, $e); } } @@ -436,7 +665,6 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) { $this->aAttribute = null; } @@ -447,12 +675,12 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -463,19 +691,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AttributeAvTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildAttributeAvQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -490,26 +718,25 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see AttributeAv::setDeleted() + * @see AttributeAv::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = AttributeAvQuery::create() + $deleteQuery = ChildAttributeAvQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -534,20 +761,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -557,16 +783,16 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(AttributeAvPeer::CREATED_AT)) { + if (!$this->isColumnModified(AttributeAvTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(AttributeAvPeer::UPDATED_AT)) { + if (!$this->isColumnModified(AttributeAvTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AttributeAvPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(AttributeAvTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -578,7 +804,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - AttributeAvPeer::addInstanceToPool($this); + AttributeAvTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -597,19 +823,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -633,15 +859,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if ($this->attributeCombinationsScheduledForDeletion !== null) { if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) { - AttributeCombinationQuery::create() + \Thelia\Model\AttributeCombinationQuery::create() ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->attributeCombinationsScheduledForDeletion = null; } } - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { + if ($this->collAttributeCombinations !== null) { + foreach ($this->collAttributeCombinations as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -650,15 +876,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if ($this->attributeAvI18nsScheduledForDeletion !== null) { if (!$this->attributeAvI18nsScheduledForDeletion->isEmpty()) { - AttributeAvI18nQuery::create() + \Thelia\Model\AttributeAvI18nQuery::create() ->filterByPrimaryKeys($this->attributeAvI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->attributeAvI18nsScheduledForDeletion = null; } } - if ($this->collAttributeAvI18ns !== null) { - foreach ($this->collAttributeAvI18ns as $referrerFK) { + if ($this->collAttributeAvI18ns !== null) { + foreach ($this->collAttributeAvI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -675,40 +901,40 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = AttributeAvPeer::ID; + $this->modifiedColumns[] = AttributeAvTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeAvPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeAvTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributeAvPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(AttributeAvTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(AttributeAvPeer::ATTRIBUTE_ID)) { - $modifiedColumns[':p' . $index++] = '`attribute_id`'; + if ($this->isColumnModified(AttributeAvTableMap::ATTRIBUTE_ID)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_ID'; } - if ($this->isColumnModified(AttributeAvPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(AttributeAvTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(AttributeAvPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(AttributeAvTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(AttributeAvPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(AttributeAvTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `attribute_av` (%s) VALUES (%s)', + 'INSERT INTO attribute_av (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -717,33 +943,33 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`attribute_id`': + case 'ATTRIBUTE_ID': $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -753,132 +979,32 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = AttributeAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = AttributeAvTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -888,7 +1014,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -921,22 +1047,22 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = AttributeAvTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getAttributeId(), @@ -944,6 +1070,12 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aAttribute) { $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -962,27 +1094,27 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = AttributeAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = AttributeAvTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1015,17 +1147,17 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = AttributeAvPeer::getFieldNames($keyType); + $keys = AttributeAvTableMap::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]]); @@ -1041,13 +1173,13 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME); + $criteria = new Criteria(AttributeAvTableMap::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); + if ($this->isColumnModified(AttributeAvTableMap::ID)) $criteria->add(AttributeAvTableMap::ID, $this->id); + if ($this->isColumnModified(AttributeAvTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeAvTableMap::ATTRIBUTE_ID, $this->attribute_id); + if ($this->isColumnModified(AttributeAvTableMap::POSITION)) $criteria->add(AttributeAvTableMap::POSITION, $this->position); + if ($this->isColumnModified(AttributeAvTableMap::CREATED_AT)) $criteria->add(AttributeAvTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AttributeAvTableMap::UPDATED_AT)) $criteria->add(AttributeAvTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1062,15 +1194,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME); - $criteria->add(AttributeAvPeer::ID, $this->id); + $criteria = new Criteria(AttributeAvTableMap::DATABASE_NAME); + $criteria->add(AttributeAvTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1080,7 +1212,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1104,9 +1236,9 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1116,12 +1248,10 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1135,8 +1265,6 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1153,8 +1281,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\AttributeAv Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1168,31 +1296,13 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildAttribute object. * - * 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) + * @param ChildAttribute $v + * @return \Thelia\Model\AttributeAv The current object (for fluent API support) * @throws PropelException */ - public function setAttribute(Attribute $v = null) + public function setAttribute(ChildAttribute $v = null) { if ($v === null) { $this->setAttributeId(NULL); @@ -1203,7 +1313,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $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 this object has already been added to the ChildAttribute object, it will not be re-added. if ($v !== null) { $v->addAttributeAv($this); } @@ -1214,17 +1324,16 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** - * Get the associated Attribute object + * Get the associated ChildAttribute object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Attribute The associated Attribute object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildAttribute The associated ChildAttribute object. * @throws PropelException */ - public function getAttribute(PropelPDO $con = null, $doQuery = true) + public function getAttribute(ConnectionInterface $con = null) { - if ($this->aAttribute === null && ($this->attribute_id !== null) && $doQuery) { - $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); + if ($this->aAttribute === null && ($this->attribute_id !== null)) { + $this->aAttribute = ChildAttributeQuery::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 @@ -1243,16 +1352,16 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('AttributeCombination' == $relationName) { - $this->initAttributeCombinations(); + return $this->initAttributeCombinations(); } if ('AttributeAvI18n' == $relationName) { - $this->initAttributeAvI18ns(); + return $this->initAttributeAvI18ns(); } } @@ -1262,21 +1371,16 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * This 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) + * @return void * @see addAttributeCombinations() */ public function clearAttributeCombinations() { - $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized - $this->collAttributeCombinationsPartial = null; - - return $this; + $this->collAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collAttributeCombinations collection loaded partially - * - * @return void + * Reset is the collAttributeCombinations collection loaded partially. */ public function resetPartialAttributeCombinations($v = true) { @@ -1290,7 +1394,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1300,25 +1404,25 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if (null !== $this->collAttributeCombinations && !$overrideExisting) { return; } - $this->collAttributeCombinations = new PropelObjectCollection(); - $this->collAttributeCombinations->setModel('AttributeCombination'); + $this->collAttributeCombinations = new ObjectCollection(); + $this->collAttributeCombinations->setModel('\Thelia\Model\AttributeCombination'); } /** - * Gets an array of AttributeCombination objects which contain a foreign key that references this object. + * Gets an array of ChildAttributeCombination objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildAttributeAv is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects * @throws PropelException */ - public function getAttributeCombinations($criteria = null, PropelPDO $con = null) + public function getAttributeCombinations($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { @@ -1326,29 +1430,31 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent // return empty collection $this->initAttributeCombinations(); } else { - $collAttributeCombinations = AttributeCombinationQuery::create(null, $criteria) + $collAttributeCombinations = ChildAttributeCombinationQuery::create(null, $criteria) ->filterByAttributeAv($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) { - $this->initAttributeCombinations(false); + $this->initAttributeCombinations(false); - foreach($collAttributeCombinations as $obj) { - if (false == $this->collAttributeCombinations->contains($obj)) { - $this->collAttributeCombinations->append($obj); + foreach ($collAttributeCombinations as $obj) { + if (false == $this->collAttributeCombinations->contains($obj)) { + $this->collAttributeCombinations->append($obj); + } } - } - $this->collAttributeCombinationsPartial = true; + $this->collAttributeCombinationsPartial = true; } $collAttributeCombinations->getInternalIterator()->rewind(); + return $collAttributeCombinations; } - if($partial && $this->collAttributeCombinations) { - foreach($this->collAttributeCombinations as $obj) { - if($obj->isNew()) { + if ($partial && $this->collAttributeCombinations) { + foreach ($this->collAttributeCombinations as $obj) { + if ($obj->isNew()) { $collAttributeCombinations[] = $obj; } } @@ -1368,15 +1474,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * It will 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) + * @param Collection $attributeCombinations A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildAttributeAv The current object (for fluent API support) */ - public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null) + public function setAttributeCombinations(Collection $attributeCombinations, ConnectionInterface $con = null) { $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - $this->attributeCombinationsScheduledForDeletion = unserialize(serialize($attributeCombinationsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->attributeCombinationsScheduledForDeletion = clone $attributeCombinationsToDelete; foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { $attributeCombinationRemoved->setAttributeAv(null); @@ -1396,13 +1506,13 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Returns the number of related AttributeCombination objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AttributeCombination objects. * @throws PropelException */ - public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { @@ -1410,10 +1520,11 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getAttributeCombinations()); } - $query = AttributeCombinationQuery::create(null, $criteria); + + $query = ChildAttributeCombinationQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1427,18 +1538,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } /** - * Method called to associate a AttributeCombination object to this object - * through the AttributeCombination foreign key attribute. + * Method called to associate a ChildAttributeCombination object to this object + * through the ChildAttributeCombination foreign key attribute. * - * @param AttributeCombination $l AttributeCombination - * @return AttributeAv The current object (for fluent API support) + * @param ChildAttributeCombination $l ChildAttributeCombination + * @return \Thelia\Model\AttributeAv The current object (for fluent API support) */ - public function addAttributeCombination(AttributeCombination $l) + public function addAttributeCombination(ChildAttributeCombination $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); } @@ -1447,7 +1559,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } /** - * @param AttributeCombination $attributeCombination The attributeCombination object to add. + * @param AttributeCombination $attributeCombination The attributeCombination object to add. */ protected function doAddAttributeCombination($attributeCombination) { @@ -1456,8 +1568,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } /** - * @param AttributeCombination $attributeCombination The attributeCombination object to remove. - * @return AttributeAv The current object (for fluent API support) + * @param AttributeCombination $attributeCombination The attributeCombination object to remove. + * @return ChildAttributeAv The current object (for fluent API support) */ public function removeAttributeCombination($attributeCombination) { @@ -1486,15 +1598,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects */ - public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Attribute', $join_behavior); + $query = ChildAttributeCombinationQuery::create(null, $criteria); + $query->joinWith('Attribute', $joinBehavior); return $this->getAttributeCombinations($query, $con); } @@ -1511,15 +1623,15 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects */ - public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Combination', $join_behavior); + $query = ChildAttributeCombinationQuery::create(null, $criteria); + $query->joinWith('Combination', $joinBehavior); return $this->getAttributeCombinations($query, $con); } @@ -1530,21 +1642,16 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collAttributeAvI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collAttributeAvI18ns collection loaded partially - * - * @return void + * Reset is the collAttributeAvI18ns collection loaded partially. */ public function resetPartialAttributeAvI18ns($v = true) { @@ -1558,7 +1665,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1568,25 +1675,25 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent if (null !== $this->collAttributeAvI18ns && !$overrideExisting) { return; } - $this->collAttributeAvI18ns = new PropelObjectCollection(); - $this->collAttributeAvI18ns->setModel('AttributeAvI18n'); + $this->collAttributeAvI18ns = new ObjectCollection(); + $this->collAttributeAvI18ns->setModel('\Thelia\Model\AttributeAvI18n'); } /** - * Gets an array of AttributeAvI18n objects which contain a foreign key that references this object. + * Gets an array of ChildAttributeAvI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildAttributeAv is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAttributeAvI18n[] List of ChildAttributeAvI18n objects * @throws PropelException */ - public function getAttributeAvI18ns($criteria = null, PropelPDO $con = null) + public function getAttributeAvI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeAvI18nsPartial && !$this->isNew(); if (null === $this->collAttributeAvI18ns || null !== $criteria || $partial) { @@ -1594,29 +1701,31 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent // return empty collection $this->initAttributeAvI18ns(); } else { - $collAttributeAvI18ns = AttributeAvI18nQuery::create(null, $criteria) + $collAttributeAvI18ns = ChildAttributeAvI18nQuery::create(null, $criteria) ->filterByAttributeAv($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collAttributeAvI18nsPartial && count($collAttributeAvI18ns)) { - $this->initAttributeAvI18ns(false); + $this->initAttributeAvI18ns(false); - foreach($collAttributeAvI18ns as $obj) { - if (false == $this->collAttributeAvI18ns->contains($obj)) { - $this->collAttributeAvI18ns->append($obj); + foreach ($collAttributeAvI18ns as $obj) { + if (false == $this->collAttributeAvI18ns->contains($obj)) { + $this->collAttributeAvI18ns->append($obj); + } } - } - $this->collAttributeAvI18nsPartial = true; + $this->collAttributeAvI18nsPartial = true; } $collAttributeAvI18ns->getInternalIterator()->rewind(); + return $collAttributeAvI18ns; } - if($partial && $this->collAttributeAvI18ns) { - foreach($this->collAttributeAvI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collAttributeAvI18ns) { + foreach ($this->collAttributeAvI18ns as $obj) { + if ($obj->isNew()) { $collAttributeAvI18ns[] = $obj; } } @@ -1636,15 +1745,19 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * It will 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) + * @param Collection $attributeAvI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildAttributeAv The current object (for fluent API support) */ - public function setAttributeAvI18ns(PropelCollection $attributeAvI18ns, PropelPDO $con = null) + public function setAttributeAvI18ns(Collection $attributeAvI18ns, ConnectionInterface $con = null) { $attributeAvI18nsToDelete = $this->getAttributeAvI18ns(new Criteria(), $con)->diff($attributeAvI18ns); - $this->attributeAvI18nsScheduledForDeletion = unserialize(serialize($attributeAvI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->attributeAvI18nsScheduledForDeletion = clone $attributeAvI18nsToDelete; foreach ($attributeAvI18nsToDelete as $attributeAvI18nRemoved) { $attributeAvI18nRemoved->setAttributeAv(null); @@ -1664,13 +1777,13 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Returns the number of related AttributeAvI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AttributeAvI18n objects. * @throws PropelException */ - public function countAttributeAvI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributeAvI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeAvI18nsPartial && !$this->isNew(); if (null === $this->collAttributeAvI18ns || null !== $criteria || $partial) { @@ -1678,10 +1791,11 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getAttributeAvI18ns()); } - $query = AttributeAvI18nQuery::create(null, $criteria); + + $query = ChildAttributeAvI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1695,13 +1809,13 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } /** - * Method called to associate a AttributeAvI18n object to this object - * through the AttributeAvI18n foreign key attribute. + * Method called to associate a ChildAttributeAvI18n object to this object + * through the ChildAttributeAvI18n foreign key attribute. * - * @param AttributeAvI18n $l AttributeAvI18n - * @return AttributeAv The current object (for fluent API support) + * @param ChildAttributeAvI18n $l ChildAttributeAvI18n + * @return \Thelia\Model\AttributeAv The current object (for fluent API support) */ - public function addAttributeAvI18n(AttributeAvI18n $l) + public function addAttributeAvI18n(ChildAttributeAvI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1711,6 +1825,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $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); } @@ -1719,7 +1834,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } /** - * @param AttributeAvI18n $attributeAvI18n The attributeAvI18n object to add. + * @param AttributeAvI18n $attributeAvI18n The attributeAvI18n object to add. */ protected function doAddAttributeAvI18n($attributeAvI18n) { @@ -1728,8 +1843,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } /** - * @param AttributeAvI18n $attributeAvI18n The attributeAvI18n object to remove. - * @return AttributeAv The current object (for fluent API support) + * @param AttributeAvI18n $attributeAvI18n The attributeAvI18n object to remove. + * @return ChildAttributeAv The current object (for fluent API support) */ public function removeAttributeAvI18n($attributeAvI18n) { @@ -1757,8 +1872,6 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1770,14 +1883,13 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collAttributeCombinations) { foreach ($this->collAttributeCombinations as $o) { $o->clearAllReferences($deep); @@ -1788,22 +1900,17 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->aAttribute instanceof Persistent) { - $this->aAttribute->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collAttributeCombinations instanceof PropelCollection) { + if ($this->collAttributeCombinations instanceof Collection) { $this->collAttributeCombinations->clearIterator(); } $this->collAttributeCombinations = null; - if ($this->collAttributeAvI18ns instanceof PropelCollection) { + if ($this->collAttributeAvI18ns instanceof Collection) { $this->collAttributeAvI18ns->clearIterator(); } $this->collAttributeAvI18ns = null; @@ -1811,23 +1918,13 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(AttributeAvTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1835,11 +1932,11 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * 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) + * @return ChildAttributeAv The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = AttributeAvPeer::UPDATED_AT; + $this->modifiedColumns[] = AttributeAvTableMap::UPDATED_AT; return $this; } @@ -1851,9 +1948,9 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return AttributeAv The current object (for fluent API support) + * @return ChildAttributeAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1874,10 +1971,10 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return AttributeAvI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildAttributeAvI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeAvI18ns) { @@ -1890,10 +1987,10 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new AttributeAvI18n(); + $translation = new ChildAttributeAvI18n(); $translation->setLocale($locale); } else { - $translation = AttributeAvI18nQuery::create() + $translation = ChildAttributeAvI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -1908,14 +2005,14 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return AttributeAv The current object (for fluent API support) + * @return ChildAttributeAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - AttributeAvI18nQuery::create() + ChildAttributeAvI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -1935,10 +2032,10 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return AttributeAvI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildAttributeAvI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -1947,7 +2044,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -1958,8 +2055,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -1971,7 +2068,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -1982,8 +2079,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -1995,7 +2092,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -2006,8 +2103,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2019,7 +2116,7 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -2030,8 +2127,8 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -2039,4 +2136,122 @@ abstract class BaseAttributeAv extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18n.php b/core/lib/Thelia/Model/Base/AttributeAvI18n.php new file mode 100644 index 000000000..bcd1c7453 --- /dev/null +++ b/core/lib/Thelia/Model/Base/AttributeAvI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\AttributeAvI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another AttributeAvI18n instance. If + * obj is an instance of AttributeAvI18n, delegates to + * equals(AttributeAvI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return AttributeAvI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return AttributeAvI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\AttributeAvI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AttributeAvI18nTableMap::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 \Thelia\Model\AttributeAvI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = AttributeAvI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = AttributeAvI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = AttributeAvI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = AttributeAvI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = AttributeAvI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeAvI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeAvI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeAvI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeAvI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeAvI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AttributeAvI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = AttributeAvI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\AttributeAvI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(AttributeAvI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildAttributeAvI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aAttributeAv = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see AttributeAvI18n::setDeleted() + * @see AttributeAvI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildAttributeAvI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME); + } + + $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); + AttributeAvI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AttributeAvI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(AttributeAvI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(AttributeAvI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(AttributeAvI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(AttributeAvI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(AttributeAvI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = AttributeAvI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['AttributeAvI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['AttributeAvI18n'][serialize($this->getPrimaryKey())] = true; + $keys = AttributeAvI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = AttributeAvI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = AttributeAvI18nTableMap::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(AttributeAvI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(AttributeAvI18nTableMap::ID)) $criteria->add(AttributeAvI18nTableMap::ID, $this->id); + if ($this->isColumnModified(AttributeAvI18nTableMap::LOCALE)) $criteria->add(AttributeAvI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(AttributeAvI18nTableMap::TITLE)) $criteria->add(AttributeAvI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(AttributeAvI18nTableMap::DESCRIPTION)) $criteria->add(AttributeAvI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(AttributeAvI18nTableMap::CHAPO)) $criteria->add(AttributeAvI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(AttributeAvI18nTableMap::POSTSCRIPTUM)) $criteria->add(AttributeAvI18nTableMap::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(AttributeAvI18nTableMap::DATABASE_NAME); + $criteria->add(AttributeAvI18nTableMap::ID, $this->id); + $criteria->add(AttributeAvI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildAttributeAv object. + * + * @param ChildAttributeAv $v + * @return \Thelia\Model\AttributeAvI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setAttributeAv(ChildAttributeAv $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 ChildAttributeAv object, it will not be re-added. + if ($v !== null) { + $v->addAttributeAvI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildAttributeAv object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildAttributeAv The associated ChildAttributeAv object. + * @throws PropelException + */ + public function getAttributeAv(ConnectionInterface $con = null) + { + if ($this->aAttributeAv === null && ($this->id !== null)) { + $this->aAttributeAv = ChildAttributeAvQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aAttributeAv = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AttributeAvI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php b/core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php new file mode 100644 index 000000000..943e453a9 --- /dev/null +++ b/core/lib/Thelia/Model/Base/AttributeAvI18nQuery.php @@ -0,0 +1,607 @@ +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[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildAttributeAvI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = AttributeAvI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(AttributeAvI18nTableMap::DATABASE_NAME); + } + $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 ConnectionInterface $con A connection object + * + * @return ChildAttributeAvI18n A model object, or null if the key is not found + */ + 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), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAttributeAvI18n(); + $obj->hydrate($row); + AttributeAvI18nTableMap::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 ConnectionInterface $con A connection object + * + * @return ChildAttributeAvI18n|array|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; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * 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 ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildAttributeAvI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(AttributeAvI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(AttributeAvI18nTableMap::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 ChildAttributeAvI18nQuery 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(AttributeAvI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(AttributeAvI18nTableMap::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 + * + * + * @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 ChildAttributeAvI18nQuery 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(AttributeAvI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AttributeAvI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AttributeAvI18nTableMap::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 ChildAttributeAvI18nQuery 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(AttributeAvI18nTableMap::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 ChildAttributeAvI18nQuery 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(AttributeAvI18nTableMap::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 ChildAttributeAvI18nQuery 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(AttributeAvI18nTableMap::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 ChildAttributeAvI18nQuery 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(AttributeAvI18nTableMap::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 ChildAttributeAvI18nQuery 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(AttributeAvI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\AttributeAv object + * + * @param \Thelia\Model\AttributeAv|ObjectCollection $attributeAv The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAttributeAvI18nQuery The current query, for fluid interface + */ + public function filterByAttributeAv($attributeAv, $comparison = null) + { + if ($attributeAv instanceof \Thelia\Model\AttributeAv) { + return $this + ->addUsingAlias(AttributeAvI18nTableMap::ID, $attributeAv->getId(), $comparison); + } elseif ($attributeAv instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AttributeAvI18nTableMap::ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByAttributeAv() only accepts arguments of type \Thelia\Model\AttributeAv or Collection'); + } + } + + /** + * 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 ChildAttributeAvI18nQuery 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 ChildAttributeAvI18n $attributeAvI18n Object to remove from the list of results + * + * @return ChildAttributeAvI18nQuery The current query, for fluid interface + */ + public function prune($attributeAvI18n = null) + { + if ($attributeAvI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(AttributeAvI18nTableMap::ID), $attributeAvI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(AttributeAvI18nTableMap::LOCALE), $attributeAvI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the attribute_av_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AttributeAvI18nTableMap::clearInstancePool(); + AttributeAvI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAttributeAvI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAttributeAvI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AttributeAvI18nTableMap::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(); + + + AttributeAvI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AttributeAvI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // AttributeAvI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php b/core/lib/Thelia/Model/Base/AttributeAvQuery.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseAttributeAvQuery.php rename to core/lib/Thelia/Model/Base/AttributeAvQuery.php index 83bf5d6ac..4f724b4f4 --- a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeAvQuery.php @@ -1,101 +1,100 @@ setModelAlias($modelAlias); } @@ -116,21 +115,21 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return AttributeAv|AttributeAv[]|mixed the result, formatted by the current formatter + * @return ChildAttributeAv|array|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 + if ((null !== ($obj = AttributeAvTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AttributeAvTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -142,46 +141,31 @@ abstract class BaseAttributeAvQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return AttributeAv A model object, or null if the key is not found - * @throws PropelException + * @return ChildAttributeAv A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `attribute_id`, `position`, `created_at`, `updated_at` FROM `attribute_av` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AttributeAv(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAttributeAv(); $obj->hydrate($row); - AttributeAvPeer::addInstanceToPool($obj, (string) $key); + AttributeAvTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -192,19 +176,19 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return AttributeAv|AttributeAv[]|mixed the result, formatted by the current formatter + * @return ChildAttributeAv|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -213,22 +197,22 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|AttributeAv[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -236,12 +220,12 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AttributeAvQuery The current query, for fluid interface + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(AttributeAvPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AttributeAvTableMap::ID, $key, Criteria::EQUAL); } /** @@ -249,12 +233,12 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AttributeAvQuery The current query, for fluid interface + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(AttributeAvPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AttributeAvTableMap::ID, $keys, Criteria::IN); } /** @@ -264,8 +248,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -274,18 +257,18 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * 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 + * @return ChildAttributeAvQuery 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); + $this->addUsingAlias(AttributeAvTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AttributeAvPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeAvTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -296,7 +279,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeAvPeer::ID, $id, $comparison); + return $this->addUsingAlias(AttributeAvTableMap::ID, $id, $comparison); } /** @@ -306,8 +289,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * $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 + * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12 * * * @see filterByAttribute() @@ -318,18 +300,18 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * 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 + * @return ChildAttributeAvQuery 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); + $this->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($attributeId['max'])) { - $this->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -340,7 +322,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attributeId, $comparison); + return $this->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attributeId, $comparison); } /** @@ -350,8 +332,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -360,18 +341,18 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * 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 + * @return ChildAttributeAvQuery 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); + $this->addUsingAlias(AttributeAvTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(AttributeAvPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeAvTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -382,7 +363,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeAvPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(AttributeAvTableMap::POSITION, $position, $comparison); } /** @@ -403,18 +384,18 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * 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 + * @return ChildAttributeAvQuery 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); + $this->addUsingAlias(AttributeAvTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributeAvPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeAvTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -425,7 +406,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeAvPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AttributeAvTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -446,18 +427,18 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * 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 + * @return ChildAttributeAvQuery 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); + $this->addUsingAlias(AttributeAvTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeAvTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -468,32 +449,31 @@ abstract class BaseAttributeAvQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AttributeAvTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Attribute object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Attribute|ObjectCollection $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. + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function filterByAttribute($attribute, $comparison = null) { - if ($attribute instanceof Attribute) { + if ($attribute instanceof \Thelia\Model\Attribute) { return $this - ->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison); - } elseif ($attribute instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison); + } elseif ($attribute instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AttributeAvTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection'); + throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection'); } } @@ -503,7 +483,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @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 + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -532,7 +512,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria /** * Use the Attribute relation Attribute object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -548,26 +528,25 @@ abstract class BaseAttributeAvQuery extends ModelCriteria } /** - * Filter the query by a related AttributeCombination object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AttributeCombination|ObjectCollection $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. + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function filterByAttributeCombination($attributeCombination, $comparison = null) { - if ($attributeCombination instanceof AttributeCombination) { + if ($attributeCombination instanceof \Thelia\Model\AttributeCombination) { return $this - ->addUsingAlias(AttributeAvPeer::ID, $attributeCombination->getAttributeAvId(), $comparison); - } elseif ($attributeCombination instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeAvTableMap::ID, $attributeCombination->getAttributeAvId(), $comparison); + } elseif ($attributeCombination instanceof ObjectCollection) { return $this ->useAttributeCombinationQuery() ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection'); + throw new PropelException('filterByAttributeCombination() only accepts arguments of type \Thelia\Model\AttributeCombination or Collection'); } } @@ -577,7 +556,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @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 + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -606,7 +585,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria /** * Use the AttributeCombination relation AttributeCombination object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -622,26 +601,25 @@ abstract class BaseAttributeAvQuery extends ModelCriteria } /** - * Filter the query by a related AttributeAvI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AttributeAvI18n|ObjectCollection $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. + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function filterByAttributeAvI18n($attributeAvI18n, $comparison = null) { - if ($attributeAvI18n instanceof AttributeAvI18n) { + if ($attributeAvI18n instanceof \Thelia\Model\AttributeAvI18n) { return $this - ->addUsingAlias(AttributeAvPeer::ID, $attributeAvI18n->getId(), $comparison); - } elseif ($attributeAvI18n instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeAvTableMap::ID, $attributeAvI18n->getId(), $comparison); + } elseif ($attributeAvI18n instanceof ObjectCollection) { return $this ->useAttributeAvI18nQuery() ->filterByPrimaryKeys($attributeAvI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeAvI18n() only accepts arguments of type AttributeAvI18n or PropelCollection'); + throw new PropelException('filterByAttributeAvI18n() only accepts arguments of type \Thelia\Model\AttributeAvI18n or Collection'); } } @@ -651,7 +629,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @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 + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function joinAttributeAvI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -680,7 +658,7 @@ abstract class BaseAttributeAvQuery extends ModelCriteria /** * Use the AttributeAvI18n relation AttributeAvI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -698,19 +676,94 @@ abstract class BaseAttributeAvQuery extends ModelCriteria /** * Exclude object from result * - * @param AttributeAv $attributeAv Object to remove from the list of results + * @param ChildAttributeAv $attributeAv Object to remove from the list of results * - * @return AttributeAvQuery The current query, for fluid interface + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function prune($attributeAv = null) { if ($attributeAv) { - $this->addUsingAlias(AttributeAvPeer::ID, $attributeAv->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(AttributeAvTableMap::ID, $attributeAv->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the attribute_av table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AttributeAvTableMap::clearInstancePool(); + AttributeAvTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAttributeAv or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAttributeAv object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AttributeAvTableMap::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(); + + + AttributeAvTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AttributeAvTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -718,31 +771,11 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AttributeAvQuery The current query, for fluid interface + * @return ChildAttributeAvQuery 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); + return $this->addUsingAlias(AttributeAvTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -750,32 +783,53 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AttributeAvQuery The current query, for fluid interface + * @return ChildAttributeAvQuery 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); + return $this->addUsingAlias(AttributeAvTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAttributeAvQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeAvTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAttributeAvQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeAvTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AttributeAvQuery The current query, for fluid interface + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AttributeAvPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AttributeAvTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AttributeAvQuery The current query, for fluid interface + * @return ChildAttributeAvQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AttributeAvPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AttributeAvTableMap::CREATED_AT); } + // i18n behavior /** @@ -785,9 +839,9 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @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 + * @return ChildAttributeAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeAvI18n'; @@ -803,9 +857,9 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @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 + * @return ChildAttributeAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -824,13 +878,13 @@ abstract class BaseAttributeAvQuery extends ModelCriteria * @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 + * @return ChildAttributeAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeAvI18n', 'Thelia\Model\AttributeAvI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'AttributeAvI18n', '\Thelia\Model\AttributeAvI18nQuery'); } -} +} // AttributeAvQuery diff --git a/core/lib/Thelia/Model/Base/AttributeCategory.php b/core/lib/Thelia/Model/Base/AttributeCategory.php new file mode 100644 index 000000000..691fa43ad --- /dev/null +++ b/core/lib/Thelia/Model/Base/AttributeCategory.php @@ -0,0 +1,1495 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another AttributeCategory instance. If + * obj is an instance of AttributeCategory, delegates to + * equals(AttributeCategory). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return AttributeCategory The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return AttributeCategory The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AttributeCategoryTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [category_id] column. + * + * @param int $v new value + * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) + */ + public function setCategoryId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->category_id !== $v) { + $this->category_id = $v; + $this->modifiedColumns[] = AttributeCategoryTableMap::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 \Thelia\Model\AttributeCategory The current object (for fluent API support) + */ + public function setAttributeId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->attribute_id !== $v) { + $this->attribute_id = $v; + $this->modifiedColumns[] = AttributeCategoryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AttributeCategoryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AttributeCategoryTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeCategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeCategoryTableMap::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = AttributeCategoryTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\AttributeCategory object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(AttributeCategoryTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildAttributeCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see AttributeCategory::setDeleted() + * @see AttributeCategory::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildAttributeCategoryQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + AttributeCategoryTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = AttributeCategoryTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCategoryTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AttributeCategoryTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(AttributeCategoryTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; + } + if ($this->isColumnModified(AttributeCategoryTableMap::ATTRIBUTE_ID)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_ID'; + } + if ($this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(AttributeCategoryTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = AttributeCategoryTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()] = true; + $keys = AttributeCategoryTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getCategoryId(), + $keys[2] => $this->getAttributeId(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = AttributeCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = AttributeCategoryTableMap::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(AttributeCategoryTableMap::DATABASE_NAME); + + if ($this->isColumnModified(AttributeCategoryTableMap::ID)) $criteria->add(AttributeCategoryTableMap::ID, $this->id); + if ($this->isColumnModified(AttributeCategoryTableMap::CATEGORY_ID)) $criteria->add(AttributeCategoryTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(AttributeCategoryTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeCategoryTableMap::ATTRIBUTE_ID, $this->attribute_id); + if ($this->isColumnModified(AttributeCategoryTableMap::CREATED_AT)) $criteria->add(AttributeCategoryTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AttributeCategoryTableMap::UPDATED_AT)) $criteria->add(AttributeCategoryTableMap::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(AttributeCategoryTableMap::DATABASE_NAME); + $criteria->add(AttributeCategoryTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $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 ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addAttributeCategory($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::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->addAttributeCategories($this); + */ + } + + return $this->aCategory; + } + + /** + * Declares an association between this object and a ChildAttribute object. + * + * @param ChildAttribute $v + * @return \Thelia\Model\AttributeCategory The current object (for fluent API support) + * @throws PropelException + */ + public function setAttribute(ChildAttribute $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 ChildAttribute object, it will not be re-added. + if ($v !== null) { + $v->addAttributeCategory($this); + } + + + return $this; + } + + + /** + * Get the associated ChildAttribute object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildAttribute The associated ChildAttribute object. + * @throws PropelException + */ + public function getAttribute(ConnectionInterface $con = null) + { + if ($this->aAttribute === null && ($this->attribute_id !== null)) { + $this->aAttribute = ChildAttributeQuery::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->addAttributeCategories($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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCategory = null; + $this->aAttribute = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AttributeCategoryTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildAttributeCategory The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AttributeCategoryTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php b/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php rename to core/lib/Thelia/Model/Base/AttributeCategoryQuery.php index f9deef20a..d325d2037 --- a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeCategoryQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -111,21 +110,21 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return AttributeCategory|AttributeCategory[]|mixed the result, formatted by the current formatter + * @return ChildAttributeCategory|array|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 + if ((null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AttributeCategoryTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -137,46 +136,31 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return AttributeCategory A model object, or null if the key is not found - * @throws PropelException + * @return ChildAttributeCategory A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `category_id`, `attribute_id`, `created_at`, `updated_at` FROM `attribute_category` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AttributeCategory(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAttributeCategory(); $obj->hydrate($row); - AttributeCategoryPeer::addInstanceToPool($obj, (string) $key); + AttributeCategoryTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -187,19 +171,19 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return AttributeCategory|AttributeCategory[]|mixed the result, formatted by the current formatter + * @return ChildAttributeCategory|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -208,22 +192,22 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|AttributeCategory[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -231,12 +215,12 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeCategoryQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(AttributeCategoryPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AttributeCategoryTableMap::ID, $key, Criteria::EQUAL); } /** @@ -244,12 +228,12 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeCategoryQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(AttributeCategoryPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AttributeCategoryTableMap::ID, $keys, Criteria::IN); } /** @@ -259,8 +243,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -269,18 +252,18 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * 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 + * @return ChildAttributeCategoryQuery 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); + $this->addUsingAlias(AttributeCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -291,7 +274,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCategoryPeer::ID, $id, $comparison); + return $this->addUsingAlias(AttributeCategoryTableMap::ID, $id, $comparison); } /** @@ -301,8 +284,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * $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 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 * * * @see filterByCategory() @@ -313,18 +295,18 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * 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 + * @return ChildAttributeCategoryQuery 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); + $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($categoryId['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -335,7 +317,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $categoryId, $comparison); } /** @@ -345,8 +327,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * $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 + * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12 * * * @see filterByAttribute() @@ -357,18 +338,18 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * 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 + * @return ChildAttributeCategoryQuery 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); + $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($attributeId['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -379,7 +360,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attributeId, $comparison); + return $this->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attributeId, $comparison); } /** @@ -400,18 +381,18 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * 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 + * @return ChildAttributeCategoryQuery 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); + $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -422,7 +403,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -443,18 +424,18 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * 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 + * @return ChildAttributeCategoryQuery 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); + $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -465,32 +446,31 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Category object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Category|ObjectCollection $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. + * @return ChildAttributeCategoryQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = null) { - if ($category instanceof Category) { + if ($category instanceof \Thelia\Model\Category) { return $this - ->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AttributeCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); } } @@ -500,7 +480,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * @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 + * @return ChildAttributeCategoryQuery The current query, for fluid interface */ public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -529,7 +509,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria /** * Use the Category relation Category object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -545,28 +525,27 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria } /** - * Filter the query by a related Attribute object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Attribute|ObjectCollection $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. + * @return ChildAttributeCategoryQuery The current query, for fluid interface */ public function filterByAttribute($attribute, $comparison = null) { - if ($attribute instanceof Attribute) { + if ($attribute instanceof \Thelia\Model\Attribute) { return $this - ->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison); - } elseif ($attribute instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison); + } elseif ($attribute instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AttributeCategoryTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection'); + throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection'); } } @@ -576,7 +555,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * @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 + * @return ChildAttributeCategoryQuery The current query, for fluid interface */ public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -605,7 +584,7 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria /** * Use the Attribute relation Attribute object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -623,19 +602,94 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria /** * Exclude object from result * - * @param AttributeCategory $attributeCategory Object to remove from the list of results + * @param ChildAttributeCategory $attributeCategory Object to remove from the list of results * - * @return AttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeCategoryQuery The current query, for fluid interface */ public function prune($attributeCategory = null) { if ($attributeCategory) { - $this->addUsingAlias(AttributeCategoryPeer::ID, $attributeCategory->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(AttributeCategoryTableMap::ID, $attributeCategory->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the attribute_category table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AttributeCategoryTableMap::clearInstancePool(); + AttributeCategoryTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAttributeCategory or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAttributeCategory object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AttributeCategoryTableMap::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(); + + + AttributeCategoryTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AttributeCategoryTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -643,31 +697,11 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeCategoryQuery 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); + return $this->addUsingAlias(AttributeCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -675,30 +709,51 @@ abstract class BaseAttributeCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeCategoryQuery 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); + return $this->addUsingAlias(AttributeCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAttributeCategoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAttributeCategoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeCategoryQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AttributeCategoryPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AttributeCategoryQuery The current query, for fluid interface + * @return ChildAttributeCategoryQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AttributeCategoryPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AttributeCategoryTableMap::CREATED_AT); } -} + +} // AttributeCategoryQuery diff --git a/core/lib/Thelia/Model/Base/AttributeCombination.php b/core/lib/Thelia/Model/Base/AttributeCombination.php new file mode 100644 index 000000000..53e671777 --- /dev/null +++ b/core/lib/Thelia/Model/Base/AttributeCombination.php @@ -0,0 +1,1643 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another AttributeCombination instance. If + * obj is an instance of AttributeCombination, delegates to + * equals(AttributeCombination). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return AttributeCombination The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return AttributeCombination The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\AttributeCombination The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AttributeCombinationTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [attribute_id] column. + * + * @param int $v new value + * @return \Thelia\Model\AttributeCombination The current object (for fluent API support) + */ + public function setAttributeId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->attribute_id !== $v) { + $this->attribute_id = $v; + $this->modifiedColumns[] = AttributeCombinationTableMap::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 \Thelia\Model\AttributeCombination The current object (for fluent API support) + */ + public function setCombinationId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->combination_id !== $v) { + $this->combination_id = $v; + $this->modifiedColumns[] = AttributeCombinationTableMap::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 \Thelia\Model\AttributeCombination The current object (for fluent API support) + */ + public function setAttributeAvId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->attribute_av_id !== $v) { + $this->attribute_av_id = $v; + $this->modifiedColumns[] = AttributeCombinationTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AttributeCombinationTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AttributeCombinationTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeCombinationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeCombinationTableMap::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeCombinationTableMap::translateFieldName('CombinationId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->combination_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeCombinationTableMap::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_av_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeCombinationTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AttributeCombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = AttributeCombinationTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\AttributeCombination object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(AttributeCombinationTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildAttributeCombinationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see AttributeCombination::setDeleted() + * @see AttributeCombination::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildAttributeCombinationQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + AttributeCombinationTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = AttributeCombinationTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCombinationTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AttributeCombinationTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_ID)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_ID'; + } + if ($this->isColumnModified(AttributeCombinationTableMap::COMBINATION_ID)) { + $modifiedColumns[':p' . $index++] = 'COMBINATION_ID'; + } + if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_AV_ID)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_ID'; + } + if ($this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(AttributeCombinationTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = AttributeCombinationTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['AttributeCombination'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['AttributeCombination'][serialize($this->getPrimaryKey())] = true; + $keys = AttributeCombinationTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = AttributeCombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = AttributeCombinationTableMap::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(AttributeCombinationTableMap::DATABASE_NAME); + + if ($this->isColumnModified(AttributeCombinationTableMap::ID)) $criteria->add(AttributeCombinationTableMap::ID, $this->id); + if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_ID, $this->attribute_id); + if ($this->isColumnModified(AttributeCombinationTableMap::COMBINATION_ID)) $criteria->add(AttributeCombinationTableMap::COMBINATION_ID, $this->combination_id); + if ($this->isColumnModified(AttributeCombinationTableMap::ATTRIBUTE_AV_ID)) $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $this->attribute_av_id); + if ($this->isColumnModified(AttributeCombinationTableMap::CREATED_AT)) $criteria->add(AttributeCombinationTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AttributeCombinationTableMap::UPDATED_AT)) $criteria->add(AttributeCombinationTableMap::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(AttributeCombinationTableMap::DATABASE_NAME); + $criteria->add(AttributeCombinationTableMap::ID, $this->id); + $criteria->add(AttributeCombinationTableMap::ATTRIBUTE_ID, $this->attribute_id); + $criteria->add(AttributeCombinationTableMap::COMBINATION_ID, $this->combination_id); + $criteria->add(AttributeCombinationTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildAttribute object. + * + * @param ChildAttribute $v + * @return \Thelia\Model\AttributeCombination The current object (for fluent API support) + * @throws PropelException + */ + public function setAttribute(ChildAttribute $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 ChildAttribute object, it will not be re-added. + if ($v !== null) { + $v->addAttributeCombination($this); + } + + + return $this; + } + + + /** + * Get the associated ChildAttribute object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildAttribute The associated ChildAttribute object. + * @throws PropelException + */ + public function getAttribute(ConnectionInterface $con = null) + { + if ($this->aAttribute === null && ($this->attribute_id !== null)) { + $this->aAttribute = ChildAttributeQuery::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 ChildAttributeAv object. + * + * @param ChildAttributeAv $v + * @return \Thelia\Model\AttributeCombination The current object (for fluent API support) + * @throws PropelException + */ + public function setAttributeAv(ChildAttributeAv $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 ChildAttributeAv object, it will not be re-added. + if ($v !== null) { + $v->addAttributeCombination($this); + } + + + return $this; + } + + + /** + * Get the associated ChildAttributeAv object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildAttributeAv The associated ChildAttributeAv object. + * @throws PropelException + */ + public function getAttributeAv(ConnectionInterface $con = null) + { + if ($this->aAttributeAv === null && ($this->attribute_av_id !== null)) { + $this->aAttributeAv = ChildAttributeAvQuery::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 ChildCombination object. + * + * @param ChildCombination $v + * @return \Thelia\Model\AttributeCombination The current object (for fluent API support) + * @throws PropelException + */ + public function setCombination(ChildCombination $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 ChildCombination object, it will not be re-added. + if ($v !== null) { + $v->addAttributeCombination($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCombination object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCombination The associated ChildCombination object. + * @throws PropelException + */ + public function getCombination(ConnectionInterface $con = null) + { + if ($this->aCombination === null && ($this->combination_id !== null)) { + $this->aCombination = ChildCombinationQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aAttribute = null; + $this->aAttributeAv = null; + $this->aCombination = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AttributeCombinationTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildAttributeCombination The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AttributeCombinationTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php b/core/lib/Thelia/Model/Base/AttributeCombinationQuery.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php rename to core/lib/Thelia/Model/Base/AttributeCombinationQuery.php index 4366cc0bb..6ccd2fcba --- a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeCombinationQuery.php @@ -1,106 +1,103 @@ setModelAlias($modelAlias); } @@ -120,23 +117,22 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * $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 + * @param array[$id, $attribute_id, $combination_id, $attribute_av_id] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return AttributeCombination|AttributeCombination[]|mixed the result, formatted by the current formatter + * @return ChildAttributeCombination|array|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 + if ((null !== ($obj = AttributeCombinationTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2], (string) $key[3]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AttributeCombinationTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -153,14 +149,13 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return AttributeCombination A model object, or null if the key is not found - * @throws PropelException + * @return ChildAttributeCombination A model object, or null if the key is not found */ 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'; + $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); @@ -170,13 +165,13 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AttributeCombination(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAttributeCombination(); $obj->hydrate($row); - AttributeCombinationPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2], (string) $key[3]))); + AttributeCombinationTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2], (string) $key[3]))); } $stmt->closeCursor(); @@ -187,19 +182,19 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return AttributeCombination|AttributeCombination[]|mixed the result, formatted by the current formatter + * @return ChildAttributeCombination|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -208,22 +203,22 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|AttributeCombination[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -231,14 +226,14 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AttributeCombinationQuery The current query, for fluid interface + * @return ChildAttributeCombinationQuery 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); + $this->addUsingAlias(AttributeCombinationTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $key[1], Criteria::EQUAL); + $this->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $key[2], Criteria::EQUAL); + $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $key[3], Criteria::EQUAL); return $this; } @@ -248,7 +243,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AttributeCombinationQuery The current query, for fluid interface + * @return ChildAttributeCombinationQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -256,12 +251,12 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria 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 = $this->getNewCriterion(AttributeCombinationTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_ID, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); - $cton2 = $this->getNewCriterion(AttributeCombinationPeer::COMBINATION_ID, $key[2], Criteria::EQUAL); + $cton2 = $this->getNewCriterion(AttributeCombinationTableMap::COMBINATION_ID, $key[2], Criteria::EQUAL); $cton0->addAnd($cton2); - $cton3 = $this->getNewCriterion(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $key[3], Criteria::EQUAL); + $cton3 = $this->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $key[3], Criteria::EQUAL); $cton0->addAnd($cton3); $this->addOr($cton0); } @@ -276,8 +271,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -286,18 +280,18 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * 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 + * @return ChildAttributeCombinationQuery 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); + $this->addUsingAlias(AttributeCombinationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCombinationTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -308,7 +302,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCombinationPeer::ID, $id, $comparison); + return $this->addUsingAlias(AttributeCombinationTableMap::ID, $id, $comparison); } /** @@ -318,8 +312,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * $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 + * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id > 12 * * * @see filterByAttribute() @@ -330,18 +323,18 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * 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 + * @return ChildAttributeCombinationQuery 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); + $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($attributeId['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -352,7 +345,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attributeId, $comparison); + return $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attributeId, $comparison); } /** @@ -362,8 +355,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * $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 + * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12 * * * @see filterByCombination() @@ -374,18 +366,18 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * 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 + * @return ChildAttributeCombinationQuery 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); + $this->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combinationId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($combinationId['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -396,7 +388,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combinationId, $comparison); + return $this->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combinationId, $comparison); } /** @@ -406,8 +398,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * $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 + * $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id > 12 * * * @see filterByAttributeAv() @@ -418,18 +409,18 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * 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 + * @return ChildAttributeCombinationQuery 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); + $this->addUsingAlias(AttributeCombinationTableMap::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); + $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $attributeAvId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -440,7 +431,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAvId, $comparison); + return $this->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $attributeAvId, $comparison); } /** @@ -461,18 +452,18 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * 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 + * @return ChildAttributeCombinationQuery 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); + $this->addUsingAlias(AttributeCombinationTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCombinationTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -483,7 +474,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AttributeCombinationTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -504,18 +495,18 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * 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 + * @return ChildAttributeCombinationQuery 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); + $this->addUsingAlias(AttributeCombinationTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeCombinationTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -526,32 +517,31 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeCombinationPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AttributeCombinationTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Attribute object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Attribute|ObjectCollection $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. + * @return ChildAttributeCombinationQuery The current query, for fluid interface */ public function filterByAttribute($attribute, $comparison = null) { - if ($attribute instanceof Attribute) { + if ($attribute instanceof \Thelia\Model\Attribute) { return $this - ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison); - } elseif ($attribute instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attribute->getId(), $comparison); + } elseif ($attribute instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection'); + throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection'); } } @@ -561,7 +551,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * @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 + * @return ChildAttributeCombinationQuery The current query, for fluid interface */ public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -590,7 +580,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria /** * Use the Attribute relation Attribute object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -606,28 +596,27 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria } /** - * Filter the query by a related AttributeAv object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AttributeAv|ObjectCollection $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. + * @return ChildAttributeCombinationQuery The current query, for fluid interface */ public function filterByAttributeAv($attributeAv, $comparison = null) { - if ($attributeAv instanceof AttributeAv) { + if ($attributeAv instanceof \Thelia\Model\AttributeAv) { return $this - ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison); - } elseif ($attributeAv instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison); + } elseif ($attributeAv instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection'); + throw new PropelException('filterByAttributeAv() only accepts arguments of type \Thelia\Model\AttributeAv or Collection'); } } @@ -637,7 +626,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * @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 + * @return ChildAttributeCombinationQuery The current query, for fluid interface */ public function joinAttributeAv($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -666,7 +655,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria /** * Use the AttributeAv relation AttributeAv object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -682,28 +671,27 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria } /** - * Filter the query by a related Combination object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Combination|ObjectCollection $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. + * @return ChildAttributeCombinationQuery The current query, for fluid interface */ public function filterByCombination($combination, $comparison = null) { - if ($combination instanceof Combination) { + if ($combination instanceof \Thelia\Model\Combination) { return $this - ->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combination->getId(), $comparison); - } elseif ($combination instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combination->getId(), $comparison); + } elseif ($combination instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AttributeCombinationTableMap::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCombination() only accepts arguments of type Combination or PropelCollection'); + throw new PropelException('filterByCombination() only accepts arguments of type \Thelia\Model\Combination or Collection'); } } @@ -713,7 +701,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * @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 + * @return ChildAttributeCombinationQuery The current query, for fluid interface */ public function joinCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -742,7 +730,7 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria /** * Use the Combination relation Combination object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -760,23 +748,98 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria /** * Exclude object from result * - * @param AttributeCombination $attributeCombination Object to remove from the list of results + * @param ChildAttributeCombination $attributeCombination Object to remove from the list of results * - * @return AttributeCombinationQuery The current query, for fluid interface + * @return ChildAttributeCombinationQuery 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->addCond('pruneCond0', $this->getAliasedColName(AttributeCombinationTableMap::ID), $attributeCombination->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(AttributeCombinationTableMap::ATTRIBUTE_ID), $attributeCombination->getAttributeId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond2', $this->getAliasedColName(AttributeCombinationTableMap::COMBINATION_ID), $attributeCombination->getCombinationId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond3', $this->getAliasedColName(AttributeCombinationTableMap::ATTRIBUTE_AV_ID), $attributeCombination->getAttributeAvId(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2', 'pruneCond3'), Criteria::LOGICAL_OR); } return $this; } + /** + * Deletes all rows from the attribute_combination table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AttributeCombinationTableMap::clearInstancePool(); + AttributeCombinationTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAttributeCombination or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAttributeCombination object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AttributeCombinationTableMap::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(); + + + AttributeCombinationTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AttributeCombinationTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -784,31 +847,11 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AttributeCombinationQuery The current query, for fluid interface + * @return ChildAttributeCombinationQuery 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); + return $this->addUsingAlias(AttributeCombinationTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -816,30 +859,51 @@ abstract class BaseAttributeCombinationQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AttributeCombinationQuery The current query, for fluid interface + * @return ChildAttributeCombinationQuery 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); + return $this->addUsingAlias(AttributeCombinationTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAttributeCombinationQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeCombinationTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAttributeCombinationQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeCombinationTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AttributeCombinationQuery The current query, for fluid interface + * @return ChildAttributeCombinationQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AttributeCombinationPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AttributeCombinationTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AttributeCombinationQuery The current query, for fluid interface + * @return ChildAttributeCombinationQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AttributeCombinationPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AttributeCombinationTableMap::CREATED_AT); } -} + +} // AttributeCombinationQuery diff --git a/core/lib/Thelia/Model/Base/AttributeI18n.php b/core/lib/Thelia/Model/Base/AttributeI18n.php new file mode 100644 index 000000000..b8865769c --- /dev/null +++ b/core/lib/Thelia/Model/Base/AttributeI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\AttributeI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another AttributeI18n instance. If + * obj is an instance of AttributeI18n, delegates to + * equals(AttributeI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return AttributeI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return AttributeI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\AttributeI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AttributeI18nTableMap::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 \Thelia\Model\AttributeI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = AttributeI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\AttributeI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = AttributeI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\AttributeI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = AttributeI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\AttributeI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = AttributeI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\AttributeI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = AttributeI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AttributeI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = AttributeI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\AttributeI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(AttributeI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildAttributeI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aAttribute = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see AttributeI18n::setDeleted() + * @see AttributeI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildAttributeI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME); + } + + $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); + AttributeI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AttributeI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(AttributeI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(AttributeI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(AttributeI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(AttributeI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(AttributeI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = AttributeI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['AttributeI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['AttributeI18n'][serialize($this->getPrimaryKey())] = true; + $keys = AttributeI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = AttributeI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = AttributeI18nTableMap::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(AttributeI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(AttributeI18nTableMap::ID)) $criteria->add(AttributeI18nTableMap::ID, $this->id); + if ($this->isColumnModified(AttributeI18nTableMap::LOCALE)) $criteria->add(AttributeI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(AttributeI18nTableMap::TITLE)) $criteria->add(AttributeI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(AttributeI18nTableMap::DESCRIPTION)) $criteria->add(AttributeI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(AttributeI18nTableMap::CHAPO)) $criteria->add(AttributeI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(AttributeI18nTableMap::POSTSCRIPTUM)) $criteria->add(AttributeI18nTableMap::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(AttributeI18nTableMap::DATABASE_NAME); + $criteria->add(AttributeI18nTableMap::ID, $this->id); + $criteria->add(AttributeI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildAttribute object. + * + * @param ChildAttribute $v + * @return \Thelia\Model\AttributeI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setAttribute(ChildAttribute $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 ChildAttribute object, it will not be re-added. + if ($v !== null) { + $v->addAttributeI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildAttribute object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildAttribute The associated ChildAttribute object. + * @throws PropelException + */ + public function getAttribute(ConnectionInterface $con = null) + { + if ($this->aAttribute === null && ($this->id !== null)) { + $this->aAttribute = ChildAttributeQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aAttribute = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AttributeI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php b/core/lib/Thelia/Model/Base/AttributeI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php rename to core/lib/Thelia/Model/Base/AttributeI18nQuery.php index f21a25d3a..c553af9a2 --- a/core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return AttributeI18n|AttributeI18n[]|mixed the result, formatted by the current formatter + * @return ChildAttributeI18n|array|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 + if ((null !== ($obj = AttributeI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AttributeI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AttributeI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return AttributeI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildAttributeI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `attribute_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AttributeI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAttributeI18n(); $obj->hydrate($row); - AttributeI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + AttributeI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return AttributeI18n|AttributeI18n[]|mixed the result, formatted by the current formatter + * @return ChildAttributeI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|AttributeI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AttributeI18nQuery The current query, for fluid interface + * @return ChildAttributeI18nQuery 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); + $this->addUsingAlias(AttributeI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(AttributeI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AttributeI18nQuery The current query, for fluid interface + * @return ChildAttributeI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(AttributeI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(AttributeI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByAttribute() @@ -270,18 +266,18 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * 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 + * @return ChildAttributeI18nQuery 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); + $this->addUsingAlias(AttributeI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AttributeI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(AttributeI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * 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 + * @return ChildAttributeI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(AttributeI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * 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 + * @return ChildAttributeI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(AttributeI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * 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 + * @return ChildAttributeI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(AttributeI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * 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 + * @return ChildAttributeI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(AttributeI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * 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 + * @return ChildAttributeI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributeI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(AttributeI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Attribute object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Attribute|ObjectCollection $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. + * @return ChildAttributeI18nQuery The current query, for fluid interface */ public function filterByAttribute($attribute, $comparison = null) { - if ($attribute instanceof Attribute) { + if ($attribute instanceof \Thelia\Model\Attribute) { return $this - ->addUsingAlias(AttributeI18nPeer::ID, $attribute->getId(), $comparison); - } elseif ($attribute instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeI18nTableMap::ID, $attribute->getId(), $comparison); + } elseif ($attribute instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(AttributeI18nPeer::ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AttributeI18nTableMap::ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection'); + throw new PropelException('filterByAttribute() only accepts arguments of type \Thelia\Model\Attribute or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria * @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 + * @return ChildAttributeI18nQuery The current query, for fluid interface */ public function joinAttribute($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria /** * Use the Attribute relation Attribute object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseAttributeI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param AttributeI18n $attributeI18n Object to remove from the list of results + * @param ChildAttributeI18n $attributeI18n Object to remove from the list of results * - * @return AttributeI18nQuery The current query, for fluid interface + * @return ChildAttributeI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(AttributeI18nTableMap::ID), $attributeI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(AttributeI18nTableMap::LOCALE), $attributeI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the attribute_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AttributeI18nTableMap::clearInstancePool(); + AttributeI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAttributeI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAttributeI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AttributeI18nTableMap::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(); + + + AttributeI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AttributeI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // AttributeI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseAttributeQuery.php b/core/lib/Thelia/Model/Base/AttributeQuery.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseAttributeQuery.php rename to core/lib/Thelia/Model/Base/AttributeQuery.php index 50ffbe964..cbb690efb --- a/core/lib/Thelia/Model/om/BaseAttributeQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeQuery.php @@ -1,103 +1,100 @@ setModelAlias($modelAlias); } @@ -118,21 +115,21 @@ abstract class BaseAttributeQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Attribute|Attribute[]|mixed the result, formatted by the current formatter + * @return ChildAttribute|array|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 + if ((null !== ($obj = AttributeTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(AttributeTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -144,46 +141,31 @@ abstract class BaseAttributeQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Attribute A model object, or null if the key is not found - * @throws PropelException + * @return ChildAttribute A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `position`, `created_at`, `updated_at` FROM `attribute` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Attribute(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAttribute(); $obj->hydrate($row); - AttributePeer::addInstanceToPool($obj, (string) $key); + AttributeTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -194,19 +176,19 @@ abstract class BaseAttributeQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Attribute|Attribute[]|mixed the result, formatted by the current formatter + * @return ChildAttribute|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -215,22 +197,22 @@ abstract class BaseAttributeQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Attribute[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -238,12 +220,12 @@ abstract class BaseAttributeQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return AttributeQuery The current query, for fluid interface + * @return ChildAttributeQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(AttributePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AttributeTableMap::ID, $key, Criteria::EQUAL); } /** @@ -251,12 +233,12 @@ abstract class BaseAttributeQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return AttributeQuery The current query, for fluid interface + * @return ChildAttributeQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(AttributePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AttributeTableMap::ID, $keys, Criteria::IN); } /** @@ -266,8 +248,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -276,18 +257,18 @@ abstract class BaseAttributeQuery extends ModelCriteria * 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 + * @return ChildAttributeQuery 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); + $this->addUsingAlias(AttributeTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(AttributePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -298,7 +279,7 @@ abstract class BaseAttributeQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributePeer::ID, $id, $comparison); + return $this->addUsingAlias(AttributeTableMap::ID, $id, $comparison); } /** @@ -308,8 +289,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -318,18 +298,18 @@ abstract class BaseAttributeQuery extends ModelCriteria * 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 + * @return ChildAttributeQuery 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); + $this->addUsingAlias(AttributeTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(AttributePeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -340,7 +320,7 @@ abstract class BaseAttributeQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributePeer::POSITION, $position, $comparison); + return $this->addUsingAlias(AttributeTableMap::POSITION, $position, $comparison); } /** @@ -361,18 +341,18 @@ abstract class BaseAttributeQuery extends ModelCriteria * 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 + * @return ChildAttributeQuery 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); + $this->addUsingAlias(AttributeTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -383,7 +363,7 @@ abstract class BaseAttributeQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AttributeTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -404,18 +384,18 @@ abstract class BaseAttributeQuery extends ModelCriteria * 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 + * @return ChildAttributeQuery 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); + $this->addUsingAlias(AttributeTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AttributeTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -426,30 +406,29 @@ abstract class BaseAttributeQuery extends ModelCriteria } } - return $this->addUsingAlias(AttributePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AttributeTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related AttributeAv object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AttributeAv|ObjectCollection $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. + * @return ChildAttributeQuery The current query, for fluid interface */ public function filterByAttributeAv($attributeAv, $comparison = null) { - if ($attributeAv instanceof AttributeAv) { + if ($attributeAv instanceof \Thelia\Model\AttributeAv) { return $this - ->addUsingAlias(AttributePeer::ID, $attributeAv->getAttributeId(), $comparison); - } elseif ($attributeAv instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeTableMap::ID, $attributeAv->getAttributeId(), $comparison); + } elseif ($attributeAv instanceof ObjectCollection) { return $this ->useAttributeAvQuery() ->filterByPrimaryKeys($attributeAv->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection'); + throw new PropelException('filterByAttributeAv() only accepts arguments of type \Thelia\Model\AttributeAv or Collection'); } } @@ -459,7 +438,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * @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 + * @return ChildAttributeQuery The current query, for fluid interface */ public function joinAttributeAv($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -488,7 +467,7 @@ abstract class BaseAttributeQuery extends ModelCriteria /** * Use the AttributeAv relation AttributeAv object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -504,26 +483,25 @@ abstract class BaseAttributeQuery extends ModelCriteria } /** - * Filter the query by a related AttributeCombination object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AttributeCombination|ObjectCollection $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. + * @return ChildAttributeQuery The current query, for fluid interface */ public function filterByAttributeCombination($attributeCombination, $comparison = null) { - if ($attributeCombination instanceof AttributeCombination) { + if ($attributeCombination instanceof \Thelia\Model\AttributeCombination) { return $this - ->addUsingAlias(AttributePeer::ID, $attributeCombination->getAttributeId(), $comparison); - } elseif ($attributeCombination instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeTableMap::ID, $attributeCombination->getAttributeId(), $comparison); + } elseif ($attributeCombination instanceof ObjectCollection) { return $this ->useAttributeCombinationQuery() ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection'); + throw new PropelException('filterByAttributeCombination() only accepts arguments of type \Thelia\Model\AttributeCombination or Collection'); } } @@ -533,7 +511,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * @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 + * @return ChildAttributeQuery The current query, for fluid interface */ public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -562,7 +540,7 @@ abstract class BaseAttributeQuery extends ModelCriteria /** * Use the AttributeCombination relation AttributeCombination object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -578,26 +556,25 @@ abstract class BaseAttributeQuery extends ModelCriteria } /** - * Filter the query by a related AttributeCategory object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AttributeCategory|ObjectCollection $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. + * @return ChildAttributeQuery The current query, for fluid interface */ public function filterByAttributeCategory($attributeCategory, $comparison = null) { - if ($attributeCategory instanceof AttributeCategory) { + if ($attributeCategory instanceof \Thelia\Model\AttributeCategory) { return $this - ->addUsingAlias(AttributePeer::ID, $attributeCategory->getAttributeId(), $comparison); - } elseif ($attributeCategory instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeTableMap::ID, $attributeCategory->getAttributeId(), $comparison); + } elseif ($attributeCategory instanceof ObjectCollection) { return $this ->useAttributeCategoryQuery() ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection'); + throw new PropelException('filterByAttributeCategory() only accepts arguments of type \Thelia\Model\AttributeCategory or Collection'); } } @@ -607,7 +584,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * @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 + * @return ChildAttributeQuery The current query, for fluid interface */ public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -636,7 +613,7 @@ abstract class BaseAttributeQuery extends ModelCriteria /** * Use the AttributeCategory relation AttributeCategory object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -652,26 +629,25 @@ abstract class BaseAttributeQuery extends ModelCriteria } /** - * Filter the query by a related AttributeI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AttributeI18n|ObjectCollection $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. + * @return ChildAttributeQuery The current query, for fluid interface */ public function filterByAttributeI18n($attributeI18n, $comparison = null) { - if ($attributeI18n instanceof AttributeI18n) { + if ($attributeI18n instanceof \Thelia\Model\AttributeI18n) { return $this - ->addUsingAlias(AttributePeer::ID, $attributeI18n->getId(), $comparison); - } elseif ($attributeI18n instanceof PropelObjectCollection) { + ->addUsingAlias(AttributeTableMap::ID, $attributeI18n->getId(), $comparison); + } elseif ($attributeI18n instanceof ObjectCollection) { return $this ->useAttributeI18nQuery() ->filterByPrimaryKeys($attributeI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeI18n() only accepts arguments of type AttributeI18n or PropelCollection'); + throw new PropelException('filterByAttributeI18n() only accepts arguments of type \Thelia\Model\AttributeI18n or Collection'); } } @@ -681,7 +657,7 @@ abstract class BaseAttributeQuery extends ModelCriteria * @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 + * @return ChildAttributeQuery The current query, for fluid interface */ public function joinAttributeI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -710,7 +686,7 @@ abstract class BaseAttributeQuery extends ModelCriteria /** * Use the AttributeI18n relation AttributeI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -729,10 +705,10 @@ abstract class BaseAttributeQuery extends ModelCriteria * 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 + * @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 + * @return ChildAttributeQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = Criteria::EQUAL) { @@ -745,19 +721,94 @@ abstract class BaseAttributeQuery extends ModelCriteria /** * Exclude object from result * - * @param Attribute $attribute Object to remove from the list of results + * @param ChildAttribute $attribute Object to remove from the list of results * - * @return AttributeQuery The current query, for fluid interface + * @return ChildAttributeQuery The current query, for fluid interface */ public function prune($attribute = null) { if ($attribute) { - $this->addUsingAlias(AttributePeer::ID, $attribute->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(AttributeTableMap::ID, $attribute->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the attribute table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AttributeTableMap::clearInstancePool(); + AttributeTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAttribute or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAttribute object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AttributeTableMap::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(); + + + AttributeTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AttributeTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -765,31 +816,11 @@ abstract class BaseAttributeQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return AttributeQuery The current query, for fluid interface + * @return ChildAttributeQuery 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); + return $this->addUsingAlias(AttributeTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -797,32 +828,53 @@ abstract class BaseAttributeQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return AttributeQuery The current query, for fluid interface + * @return ChildAttributeQuery 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); + return $this->addUsingAlias(AttributeTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAttributeQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AttributeTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAttributeQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AttributeTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return AttributeQuery The current query, for fluid interface + * @return ChildAttributeQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(AttributePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(AttributeTableMap::CREATED_AT); } /** * Order by create date asc * - * @return AttributeQuery The current query, for fluid interface + * @return ChildAttributeQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(AttributePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(AttributeTableMap::CREATED_AT); } + // i18n behavior /** @@ -832,9 +884,9 @@ abstract class BaseAttributeQuery extends ModelCriteria * @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 + * @return ChildAttributeQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeI18n'; @@ -850,9 +902,9 @@ abstract class BaseAttributeQuery extends ModelCriteria * @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 + * @return ChildAttributeQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -871,13 +923,13 @@ abstract class BaseAttributeQuery extends ModelCriteria * @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 + * @return ChildAttributeI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeI18n', 'Thelia\Model\AttributeI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'AttributeI18n', '\Thelia\Model\AttributeI18nQuery'); } -} +} // AttributeQuery diff --git a/core/lib/Thelia/Model/om/BaseCategory.php b/core/lib/Thelia/Model/Base/Category.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseCategory.php rename to core/lib/Thelia/Model/Base/Category.php index f28b3b513..a5df03229 --- a/core/lib/Thelia/Model/om/BaseCategory.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -1,76 +1,84 @@ applyDefaultValues(); } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Category instance. If + * obj is an instance of Category, delegates to + * equals(Category). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Category The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Category The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [parent] column value. * - * @return int + * @return int */ public function getParent() { + return $this->parent; } /** * Get the [link] column value. * - * @return string + * @return string */ public function getLink() { + return $this->link; } /** * Get the [visible] column value. * - * @return int + * @return int */ public function getVisible() { + return $this->visible; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -391,89 +638,50 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version] column value. * - * @return int + * @return int */ public function getVersion() { + return $this->version; } @@ -481,67 +689,48 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getVersionCreatedAt($format = NULL) { - 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; + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version_created_by] column value. * - * @return string + * @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) + * @param int $v new value + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = CategoryPeer::ID; + $this->modifiedColumns[] = CategoryTableMap::ID; } @@ -551,18 +740,18 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [parent] column. * - * @param int $v new value - * @return Category The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setParent($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->parent !== $v) { $this->parent = $v; - $this->modifiedColumns[] = CategoryPeer::PARENT; + $this->modifiedColumns[] = CategoryTableMap::PARENT; } @@ -572,18 +761,18 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [link] column. * - * @param string $v new value - * @return Category The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setLink($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->link !== $v) { $this->link = $v; - $this->modifiedColumns[] = CategoryPeer::LINK; + $this->modifiedColumns[] = CategoryTableMap::LINK; } @@ -593,18 +782,18 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [visible] column. * - * @param int $v new value - * @return Category The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setVisible($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->visible !== $v) { $this->visible = $v; - $this->modifiedColumns[] = CategoryPeer::VISIBLE; + $this->modifiedColumns[] = CategoryTableMap::VISIBLE; } @@ -614,18 +803,18 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return Category The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = CategoryPeer::POSITION; + $this->modifiedColumns[] = CategoryTableMap::POSITION; } @@ -635,19 +824,17 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CategoryTableMap::CREATED_AT; } } // if either are not null @@ -658,19 +845,17 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CategoryTableMap::UPDATED_AT; } } // if either are not null @@ -681,18 +866,18 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [version] column. * - * @param int $v new value - * @return Category The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setVersion($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->version !== $v) { $this->version = $v; - $this->modifiedColumns[] = CategoryPeer::VERSION; + $this->modifiedColumns[] = CategoryTableMap::VERSION; } @@ -702,19 +887,17 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setVersionCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = CategoryTableMap::VERSION_CREATED_AT; } } // if either are not null @@ -725,18 +908,18 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [version_created_by] column. * - * @param string $v new value - * @return Category The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Category The current object (for fluent API support) */ public function setVersionCreatedBy($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->version_created_by !== $v) { $this->version_created_by = $v; - $this->modifiedColumns[] = CategoryPeer::VERSION_CREATED_BY; + $this->modifiedColumns[] = CategoryTableMap::VERSION_CREATED_BY; } @@ -757,7 +940,7 @@ abstract class BaseCategory extends BaseObject implements Persistent return false; } - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -769,26 +952,59 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $this->parent = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)]; + $this->link = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CategoryTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CategoryTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CategoryTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -796,11 +1012,11 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 10; // 10 = CategoryPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 10; // 10 = CategoryTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Category object", $e); + throw new PropelException("Error populating \Thelia\Model\Category object", 0, $e); } } @@ -819,7 +1035,6 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -827,12 +1042,12 @@ abstract class BaseCategory extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -843,27 +1058,27 @@ abstract class BaseCategory extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CategoryTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? - $this->collProductCategorys = null; + $this->collProductCategories = null; - $this->collFeatureCategorys = null; + $this->collFeatureCategories = null; - $this->collAttributeCategorys = null; + $this->collAttributeCategories = null; $this->collContentAssocs = null; @@ -886,26 +1101,25 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Category::setDeleted() + * @see Category::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = CategoryQuery::create() + $deleteQuery = ChildCategoryQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -930,20 +1144,19 @@ abstract class BaseCategory extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -953,7 +1166,7 @@ abstract class BaseCategory extends BaseObject implements Persistent // versionable behavior if ($this->isVersioningNecessary()) { $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1); - if (!$this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) { + if (!$this->isColumnModified(CategoryTableMap::VERSION_CREATED_AT)) { $this->setVersionCreatedAt(time()); } $createVersion = true; // for postSave hook @@ -961,16 +1174,16 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(CategoryPeer::CREATED_AT)) { + if (!$this->isColumnModified(CategoryTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(CategoryPeer::UPDATED_AT)) { + if (!$this->isColumnModified(CategoryTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CategoryPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(CategoryTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -986,7 +1199,7 @@ abstract class BaseCategory extends BaseObject implements Persistent if (isset($createVersion)) { $this->addVersion($con); } - CategoryPeer::addInstanceToPool($this); + CategoryTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1005,12 +1218,12 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -1030,10 +1243,11 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->productsScheduledForDeletion !== null) { if (!$this->productsScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->productsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($remotePk, $pk); } + ProductCategoryQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -1056,10 +1270,11 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->featuresScheduledForDeletion !== null) { if (!$this->featuresScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->featuresScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($pk, $remotePk); } + FeatureCategoryQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -1082,10 +1297,11 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->attributesScheduledForDeletion !== null) { if (!$this->attributesScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->attributesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($pk, $remotePk); } + AttributeCategoryQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -1105,51 +1321,51 @@ abstract class BaseCategory extends BaseObject implements Persistent } } - if ($this->productCategorysScheduledForDeletion !== null) { - if (!$this->productCategorysScheduledForDeletion->isEmpty()) { - ProductCategoryQuery::create() - ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false)) + if ($this->productCategoriesScheduledForDeletion !== null) { + if (!$this->productCategoriesScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProductCategoryQuery::create() + ->filterByPrimaryKeys($this->productCategoriesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->productCategorysScheduledForDeletion = null; + $this->productCategoriesScheduledForDeletion = null; } } - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { + if ($this->collProductCategories !== null) { + foreach ($this->collProductCategories 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)) + if ($this->featureCategoriesScheduledForDeletion !== null) { + if (!$this->featureCategoriesScheduledForDeletion->isEmpty()) { + \Thelia\Model\FeatureCategoryQuery::create() + ->filterByPrimaryKeys($this->featureCategoriesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->featureCategorysScheduledForDeletion = null; + $this->featureCategoriesScheduledForDeletion = null; } } - if ($this->collFeatureCategorys !== null) { - foreach ($this->collFeatureCategorys as $referrerFK) { + if ($this->collFeatureCategories !== null) { + foreach ($this->collFeatureCategories 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)) + if ($this->attributeCategoriesScheduledForDeletion !== null) { + if (!$this->attributeCategoriesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AttributeCategoryQuery::create() + ->filterByPrimaryKeys($this->attributeCategoriesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->attributeCategorysScheduledForDeletion = null; + $this->attributeCategoriesScheduledForDeletion = null; } } - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { + if ($this->collAttributeCategories !== null) { + foreach ($this->collAttributeCategories as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1158,16 +1374,15 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->contentAssocsScheduledForDeletion !== null) { if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { - // need to save related object because we set the relation to null - $contentAssoc->save($con); - } + \Thelia\Model\ContentAssocQuery::create() + ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->contentAssocsScheduledForDeletion = null; } } - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { + if ($this->collContentAssocs !== null) { + foreach ($this->collContentAssocs as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1176,16 +1391,15 @@ abstract class BaseCategory extends BaseObject implements Persistent 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); - } + \Thelia\Model\ImageQuery::create() + ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->imagesScheduledForDeletion = null; } } - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { + if ($this->collImages !== null) { + foreach ($this->collImages as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1194,16 +1408,15 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->documentsScheduledForDeletion !== null) { if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } + \Thelia\Model\DocumentQuery::create() + ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->documentsScheduledForDeletion = null; } } - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1212,16 +1425,15 @@ abstract class BaseCategory extends BaseObject implements Persistent 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); - } + \Thelia\Model\RewritingQuery::create() + ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->rewritingsScheduledForDeletion = null; } } - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { + if ($this->collRewritings !== null) { + foreach ($this->collRewritings as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1230,15 +1442,15 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->categoryI18nsScheduledForDeletion !== null) { if (!$this->categoryI18nsScheduledForDeletion->isEmpty()) { - CategoryI18nQuery::create() + \Thelia\Model\CategoryI18nQuery::create() ->filterByPrimaryKeys($this->categoryI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->categoryI18nsScheduledForDeletion = null; } } - if ($this->collCategoryI18ns !== null) { - foreach ($this->collCategoryI18ns as $referrerFK) { + if ($this->collCategoryI18ns !== null) { + foreach ($this->collCategoryI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1247,15 +1459,15 @@ abstract class BaseCategory extends BaseObject implements Persistent if ($this->categoryVersionsScheduledForDeletion !== null) { if (!$this->categoryVersionsScheduledForDeletion->isEmpty()) { - CategoryVersionQuery::create() + \Thelia\Model\CategoryVersionQuery::create() ->filterByPrimaryKeys($this->categoryVersionsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->categoryVersionsScheduledForDeletion = null; } } - if ($this->collCategoryVersions !== null) { - foreach ($this->collCategoryVersions as $referrerFK) { + if ($this->collCategoryVersions !== null) { + foreach ($this->collCategoryVersions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1272,55 +1484,55 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = CategoryPeer::ID; + $this->modifiedColumns[] = CategoryTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CategoryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(CategoryTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(CategoryPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`parent`'; + if ($this->isColumnModified(CategoryTableMap::PARENT)) { + $modifiedColumns[':p' . $index++] = 'PARENT'; } - if ($this->isColumnModified(CategoryPeer::LINK)) { - $modifiedColumns[':p' . $index++] = '`link`'; + if ($this->isColumnModified(CategoryTableMap::LINK)) { + $modifiedColumns[':p' . $index++] = 'LINK'; } - if ($this->isColumnModified(CategoryPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; + if ($this->isColumnModified(CategoryTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; } - if ($this->isColumnModified(CategoryPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(CategoryTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(CategoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(CategoryTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(CategoryTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } - if ($this->isColumnModified(CategoryPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`version`'; + if ($this->isColumnModified(CategoryTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; } - if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`version_created_at`'; + if ($this->isColumnModified(CategoryTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; } - if ($this->isColumnModified(CategoryPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`version_created_by`'; + if ($this->isColumnModified(CategoryTableMap::VERSION_CREATED_BY)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY'; } $sql = sprintf( - 'INSERT INTO `category` (%s) VALUES (%s)', + 'INSERT INTO category (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1329,34 +1541,34 @@ abstract class BaseCategory extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`parent`': + case 'PARENT': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case '`link`': + case 'LINK': $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR); break; - case '`visible`': + case 'VISIBLE': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version`': + 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); + case 'VERSION_CREATED_AT': + $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version_created_by`': + case 'VERSION_CREATED_BY': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1364,13 +1576,13 @@ abstract class BaseCategory extends BaseObject implements Persistent $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -1380,176 +1592,32 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1559,7 +1627,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1607,22 +1675,22 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = CategoryTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getParent(), @@ -1635,15 +1703,21 @@ abstract class BaseCategory extends BaseObject implements Persistent $keys[8] => $this->getVersionCreatedAt(), $keys[9] => $this->getVersionCreatedBy(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { - if (null !== $this->collProductCategorys) { - $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collProductCategories) { + $result['ProductCategories'] = $this->collProductCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collFeatureCategorys) { - $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collFeatureCategories) { + $result['FeatureCategories'] = $this->collFeatureCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collAttributeCategorys) { - $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collAttributeCategories) { + $result['AttributeCategories'] = $this->collAttributeCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collContentAssocs) { $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1671,27 +1745,27 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1739,17 +1813,17 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = CategoryPeer::getFieldNames($keyType); + $keys = CategoryTableMap::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]]); @@ -1770,18 +1844,18 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(CategoryPeer::DATABASE_NAME); + $criteria = new Criteria(CategoryTableMap::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); + if ($this->isColumnModified(CategoryTableMap::ID)) $criteria->add(CategoryTableMap::ID, $this->id); + if ($this->isColumnModified(CategoryTableMap::PARENT)) $criteria->add(CategoryTableMap::PARENT, $this->parent); + if ($this->isColumnModified(CategoryTableMap::LINK)) $criteria->add(CategoryTableMap::LINK, $this->link); + if ($this->isColumnModified(CategoryTableMap::VISIBLE)) $criteria->add(CategoryTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(CategoryTableMap::POSITION)) $criteria->add(CategoryTableMap::POSITION, $this->position); + if ($this->isColumnModified(CategoryTableMap::CREATED_AT)) $criteria->add(CategoryTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CategoryTableMap::UPDATED_AT)) $criteria->add(CategoryTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(CategoryTableMap::VERSION)) $criteria->add(CategoryTableMap::VERSION, $this->version); + if ($this->isColumnModified(CategoryTableMap::VERSION_CREATED_AT)) $criteria->add(CategoryTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(CategoryTableMap::VERSION_CREATED_BY)) $criteria->add(CategoryTableMap::VERSION_CREATED_BY, $this->version_created_by); return $criteria; } @@ -1796,15 +1870,15 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(CategoryPeer::DATABASE_NAME); - $criteria->add(CategoryPeer::ID, $this->id); + $criteria = new Criteria(CategoryTableMap::DATABASE_NAME); + $criteria->add(CategoryTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1814,7 +1888,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1838,9 +1912,9 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1855,26 +1929,24 @@ abstract class BaseCategory extends BaseObject implements Persistent $copyObj->setVersionCreatedAt($this->getVersionCreatedAt()); $copyObj->setVersionCreatedBy($this->getVersionCreatedBy()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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) { + foreach ($this->getProductCategories() 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) { + foreach ($this->getFeatureCategories() 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) { + foreach ($this->getAttributeCategories() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addAttributeCategory($relObj->copy($deepCopy)); } @@ -1916,8 +1988,6 @@ abstract class BaseCategory extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1934,8 +2004,8 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Category Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1948,168 +2018,147 @@ abstract class BaseCategory extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('ProductCategory' == $relationName) { - $this->initProductCategorys(); + return $this->initProductCategories(); } if ('FeatureCategory' == $relationName) { - $this->initFeatureCategorys(); + return $this->initFeatureCategories(); } if ('AttributeCategory' == $relationName) { - $this->initAttributeCategorys(); + return $this->initAttributeCategories(); } if ('ContentAssoc' == $relationName) { - $this->initContentAssocs(); + return $this->initContentAssocs(); } if ('Image' == $relationName) { - $this->initImages(); + return $this->initImages(); } if ('Document' == $relationName) { - $this->initDocuments(); + return $this->initDocuments(); } if ('Rewriting' == $relationName) { - $this->initRewritings(); + return $this->initRewritings(); } if ('CategoryI18n' == $relationName) { - $this->initCategoryI18ns(); + return $this->initCategoryI18ns(); } if ('CategoryVersion' == $relationName) { - $this->initCategoryVersions(); + return $this->initCategoryVersions(); } } /** - * Clears out the collProductCategorys collection + * Clears out the collProductCategories collection * * This 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 + * @see addProductCategories() */ - public function resetPartialProductCategorys($v = true) + public function clearProductCategories() { - $this->collProductCategorysPartial = $v; + $this->collProductCategories = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collProductCategorys collection. + * Reset is the collProductCategories collection loaded partially. + */ + public function resetPartialProductCategories($v = true) + { + $this->collProductCategoriesPartial = $v; + } + + /** + * Initializes the collProductCategories collection. * - * By default this just sets the collProductCategorys collection to an empty array (like clearcollProductCategorys()); + * By default this just sets the collProductCategories collection to an empty array (like clearcollProductCategories()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initProductCategories($overrideExisting = true) { - if (null !== $this->collProductCategorys && !$overrideExisting) { + if (null !== $this->collProductCategories && !$overrideExisting) { return; } - $this->collProductCategorys = new PropelObjectCollection(); - $this->collProductCategorys->setModel('ProductCategory'); + $this->collProductCategories = new ObjectCollection(); + $this->collProductCategories->setModel('\Thelia\Model\ProductCategory'); } /** - * Gets an array of ProductCategory objects which contain a foreign key that references this object. + * Gets an array of ChildProductCategory objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCategory is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProductCategory[] List of ChildProductCategory objects * @throws PropelException */ - public function getProductCategorys($criteria = null, PropelPDO $con = null) + public function getProductCategories($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { + $partial = $this->collProductCategoriesPartial && !$this->isNew(); + if (null === $this->collProductCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductCategories) { // return empty collection - $this->initProductCategorys(); + $this->initProductCategories(); } else { - $collProductCategorys = ProductCategoryQuery::create(null, $criteria) + $collProductCategories = ChildProductCategoryQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) { - $this->initProductCategorys(false); + if (false !== $this->collProductCategoriesPartial && count($collProductCategories)) { + $this->initProductCategories(false); - foreach($collProductCategorys as $obj) { - if (false == $this->collProductCategorys->contains($obj)) { - $this->collProductCategorys->append($obj); + foreach ($collProductCategories as $obj) { + if (false == $this->collProductCategories->contains($obj)) { + $this->collProductCategories->append($obj); + } } - } - $this->collProductCategorysPartial = true; + $this->collProductCategoriesPartial = true; } - $collProductCategorys->getInternalIterator()->rewind(); - return $collProductCategorys; + $collProductCategories->getInternalIterator()->rewind(); + + return $collProductCategories; } - if($partial && $this->collProductCategorys) { - foreach($this->collProductCategorys as $obj) { - if($obj->isNew()) { - $collProductCategorys[] = $obj; + if ($partial && $this->collProductCategories) { + foreach ($this->collProductCategories as $obj) { + if ($obj->isNew()) { + $collProductCategories[] = $obj; } } } - $this->collProductCategorys = $collProductCategorys; - $this->collProductCategorysPartial = false; + $this->collProductCategories = $collProductCategories; + $this->collProductCategoriesPartial = false; } } - return $this->collProductCategorys; + return $this->collProductCategories; } /** @@ -2118,27 +2167,31 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $productCategories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) + public function setProductCategories(Collection $productCategories, ConnectionInterface $con = null) { - $productCategorysToDelete = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); + $productCategoriesToDelete = $this->getProductCategories(new Criteria(), $con)->diff($productCategories); - $this->productCategorysScheduledForDeletion = unserialize(serialize($productCategorysToDelete)); - foreach ($productCategorysToDelete as $productCategoryRemoved) { + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->productCategoriesScheduledForDeletion = clone $productCategoriesToDelete; + + foreach ($productCategoriesToDelete as $productCategoryRemoved) { $productCategoryRemoved->setCategory(null); } - $this->collProductCategorys = null; - foreach ($productCategorys as $productCategory) { + $this->collProductCategories = null; + foreach ($productCategories as $productCategory) { $this->addProductCategory($productCategory); } - $this->collProductCategorys = $productCategorys; - $this->collProductCategorysPartial = false; + $this->collProductCategories = $productCategories; + $this->collProductCategoriesPartial = false; return $this; } @@ -2146,24 +2199,25 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the number of related ProductCategory objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ProductCategory objects. * @throws PropelException */ - public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countProductCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { + $partial = $this->collProductCategoriesPartial && !$this->isNew(); + if (null === $this->collProductCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductCategories) { return 0; } - if($partial && !$criteria) { - return count($this->getProductCategorys()); + if ($partial && !$criteria) { + return count($this->getProductCategories()); } - $query = ProductCategoryQuery::create(null, $criteria); + + $query = ChildProductCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2173,23 +2227,24 @@ abstract class BaseCategory extends BaseObject implements Persistent ->count($con); } - return count($this->collProductCategorys); + return count($this->collProductCategories); } /** - * Method called to associate a ProductCategory object to this object - * through the ProductCategory foreign key attribute. + * Method called to associate a ChildProductCategory object to this object + * through the ChildProductCategory foreign key attribute. * - * @param ProductCategory $l ProductCategory - * @return Category The current object (for fluent API support) + * @param ChildProductCategory $l ChildProductCategory + * @return \Thelia\Model\Category The current object (for fluent API support) */ - public function addProductCategory(ProductCategory $l) + public function addProductCategory(ChildProductCategory $l) { - if ($this->collProductCategorys === null) { - $this->initProductCategorys(); - $this->collProductCategorysPartial = true; + if ($this->collProductCategories === null) { + $this->initProductCategories(); + $this->collProductCategoriesPartial = true; } - if (!in_array($l, $this->collProductCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collProductCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddProductCategory($l); } @@ -2197,27 +2252,27 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param ProductCategory $productCategory The productCategory object to add. + * @param ProductCategory $productCategory The productCategory object to add. */ protected function doAddProductCategory($productCategory) { - $this->collProductCategorys[]= $productCategory; + $this->collProductCategories[]= $productCategory; $productCategory->setCategory($this); } /** - * @param ProductCategory $productCategory The productCategory object to remove. - * @return Category The current object (for fluent API support) + * @param ProductCategory $productCategory The productCategory object to remove. + * @return ChildCategory 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(); + if ($this->getProductCategories()->contains($productCategory)) { + $this->collProductCategories->remove($this->collProductCategories->search($productCategory)); + if (null === $this->productCategoriesScheduledForDeletion) { + $this->productCategoriesScheduledForDeletion = clone $this->collProductCategories; + $this->productCategoriesScheduledForDeletion->clear(); } - $this->productCategorysScheduledForDeletion[]= clone $productCategory; + $this->productCategoriesScheduledForDeletion[]= clone $productCategory; $productCategory->setCategory(null); } @@ -2230,129 +2285,126 @@ abstract class BaseCategory extends BaseObject implements Persistent * an identical criteria, it returns the collection. * Otherwise if this Category is new, it will return * an empty collection; or if this Category has previously - * been saved, it will retrieve related ProductCategorys from storage. + * been saved, it will retrieve related ProductCategories from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProductCategory[] List of ChildProductCategory objects */ - public function getProductCategorysJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getProductCategoriesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ProductCategoryQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildProductCategoryQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); - return $this->getProductCategorys($query, $con); + return $this->getProductCategories($query, $con); } /** - * Clears out the collFeatureCategorys collection + * Clears out the collFeatureCategories collection * * This 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 + * @see addFeatureCategories() */ - public function resetPartialFeatureCategorys($v = true) + public function clearFeatureCategories() { - $this->collFeatureCategorysPartial = $v; + $this->collFeatureCategories = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collFeatureCategorys collection. + * Reset is the collFeatureCategories collection loaded partially. + */ + public function resetPartialFeatureCategories($v = true) + { + $this->collFeatureCategoriesPartial = $v; + } + + /** + * Initializes the collFeatureCategories collection. * - * By default this just sets the collFeatureCategorys collection to an empty array (like clearcollFeatureCategorys()); + * By default this just sets the collFeatureCategories collection to an empty array (like clearcollFeatureCategories()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initFeatureCategories($overrideExisting = true) { - if (null !== $this->collFeatureCategorys && !$overrideExisting) { + if (null !== $this->collFeatureCategories && !$overrideExisting) { return; } - $this->collFeatureCategorys = new PropelObjectCollection(); - $this->collFeatureCategorys->setModel('FeatureCategory'); + $this->collFeatureCategories = new ObjectCollection(); + $this->collFeatureCategories->setModel('\Thelia\Model\FeatureCategory'); } /** - * Gets an array of FeatureCategory objects which contain a foreign key that references this object. + * Gets an array of ChildFeatureCategory objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCategory is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects * @throws PropelException */ - public function getFeatureCategorys($criteria = null, PropelPDO $con = null) + public function getFeatureCategories($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategorys) { + $partial = $this->collFeatureCategoriesPartial && !$this->isNew(); + if (null === $this->collFeatureCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureCategories) { // return empty collection - $this->initFeatureCategorys(); + $this->initFeatureCategories(); } else { - $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria) + $collFeatureCategories = ChildFeatureCategoryQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) { - $this->initFeatureCategorys(false); + if (false !== $this->collFeatureCategoriesPartial && count($collFeatureCategories)) { + $this->initFeatureCategories(false); - foreach($collFeatureCategorys as $obj) { - if (false == $this->collFeatureCategorys->contains($obj)) { - $this->collFeatureCategorys->append($obj); + foreach ($collFeatureCategories as $obj) { + if (false == $this->collFeatureCategories->contains($obj)) { + $this->collFeatureCategories->append($obj); + } } - } - $this->collFeatureCategorysPartial = true; + $this->collFeatureCategoriesPartial = true; } - $collFeatureCategorys->getInternalIterator()->rewind(); - return $collFeatureCategorys; + $collFeatureCategories->getInternalIterator()->rewind(); + + return $collFeatureCategories; } - if($partial && $this->collFeatureCategorys) { - foreach($this->collFeatureCategorys as $obj) { - if($obj->isNew()) { - $collFeatureCategorys[] = $obj; + if ($partial && $this->collFeatureCategories) { + foreach ($this->collFeatureCategories as $obj) { + if ($obj->isNew()) { + $collFeatureCategories[] = $obj; } } } - $this->collFeatureCategorys = $collFeatureCategorys; - $this->collFeatureCategorysPartial = false; + $this->collFeatureCategories = $collFeatureCategories; + $this->collFeatureCategoriesPartial = false; } } - return $this->collFeatureCategorys; + return $this->collFeatureCategories; } /** @@ -2361,27 +2413,28 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $featureCategories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null) + public function setFeatureCategories(Collection $featureCategories, ConnectionInterface $con = null) { - $featureCategorysToDelete = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); + $featureCategoriesToDelete = $this->getFeatureCategories(new Criteria(), $con)->diff($featureCategories); - $this->featureCategorysScheduledForDeletion = unserialize(serialize($featureCategorysToDelete)); - foreach ($featureCategorysToDelete as $featureCategoryRemoved) { + $this->featureCategoriesScheduledForDeletion = $featureCategoriesToDelete; + + foreach ($featureCategoriesToDelete as $featureCategoryRemoved) { $featureCategoryRemoved->setCategory(null); } - $this->collFeatureCategorys = null; - foreach ($featureCategorys as $featureCategory) { + $this->collFeatureCategories = null; + foreach ($featureCategories as $featureCategory) { $this->addFeatureCategory($featureCategory); } - $this->collFeatureCategorys = $featureCategorys; - $this->collFeatureCategorysPartial = false; + $this->collFeatureCategories = $featureCategories; + $this->collFeatureCategoriesPartial = false; return $this; } @@ -2389,24 +2442,25 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the number of related FeatureCategory objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FeatureCategory objects. * @throws PropelException */ - public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFeatureCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategorys) { + $partial = $this->collFeatureCategoriesPartial && !$this->isNew(); + if (null === $this->collFeatureCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureCategories) { return 0; } - if($partial && !$criteria) { - return count($this->getFeatureCategorys()); + if ($partial && !$criteria) { + return count($this->getFeatureCategories()); } - $query = FeatureCategoryQuery::create(null, $criteria); + + $query = ChildFeatureCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2416,23 +2470,24 @@ abstract class BaseCategory extends BaseObject implements Persistent ->count($con); } - return count($this->collFeatureCategorys); + return count($this->collFeatureCategories); } /** - * Method called to associate a FeatureCategory object to this object - * through the FeatureCategory foreign key attribute. + * Method called to associate a ChildFeatureCategory object to this object + * through the ChildFeatureCategory foreign key attribute. * - * @param FeatureCategory $l FeatureCategory - * @return Category The current object (for fluent API support) + * @param ChildFeatureCategory $l ChildFeatureCategory + * @return \Thelia\Model\Category The current object (for fluent API support) */ - public function addFeatureCategory(FeatureCategory $l) + public function addFeatureCategory(ChildFeatureCategory $l) { - if ($this->collFeatureCategorys === null) { - $this->initFeatureCategorys(); - $this->collFeatureCategorysPartial = true; + if ($this->collFeatureCategories === null) { + $this->initFeatureCategories(); + $this->collFeatureCategoriesPartial = true; } - if (!in_array($l, $this->collFeatureCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collFeatureCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureCategory($l); } @@ -2440,27 +2495,27 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param FeatureCategory $featureCategory The featureCategory object to add. + * @param FeatureCategory $featureCategory The featureCategory object to add. */ protected function doAddFeatureCategory($featureCategory) { - $this->collFeatureCategorys[]= $featureCategory; + $this->collFeatureCategories[]= $featureCategory; $featureCategory->setCategory($this); } /** - * @param FeatureCategory $featureCategory The featureCategory object to remove. - * @return Category The current object (for fluent API support) + * @param FeatureCategory $featureCategory The featureCategory object to remove. + * @return ChildCategory 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(); + if ($this->getFeatureCategories()->contains($featureCategory)) { + $this->collFeatureCategories->remove($this->collFeatureCategories->search($featureCategory)); + if (null === $this->featureCategoriesScheduledForDeletion) { + $this->featureCategoriesScheduledForDeletion = clone $this->collFeatureCategories; + $this->featureCategoriesScheduledForDeletion->clear(); } - $this->featureCategorysScheduledForDeletion[]= clone $featureCategory; + $this->featureCategoriesScheduledForDeletion[]= clone $featureCategory; $featureCategory->setCategory(null); } @@ -2473,129 +2528,126 @@ abstract class BaseCategory extends BaseObject implements Persistent * an identical criteria, it returns the collection. * Otherwise if this Category is new, it will return * an empty collection; or if this Category has previously - * been saved, it will retrieve related FeatureCategorys from storage. + * been saved, it will retrieve related FeatureCategories from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects */ - public function getFeatureCategorysJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureCategoriesJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = FeatureCategoryQuery::create(null, $criteria); - $query->joinWith('Feature', $join_behavior); + $query = ChildFeatureCategoryQuery::create(null, $criteria); + $query->joinWith('Feature', $joinBehavior); - return $this->getFeatureCategorys($query, $con); + return $this->getFeatureCategories($query, $con); } /** - * Clears out the collAttributeCategorys collection + * Clears out the collAttributeCategories collection * * This 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 + * @see addAttributeCategories() */ - public function resetPartialAttributeCategorys($v = true) + public function clearAttributeCategories() { - $this->collAttributeCategorysPartial = $v; + $this->collAttributeCategories = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collAttributeCategorys collection. + * Reset is the collAttributeCategories collection loaded partially. + */ + public function resetPartialAttributeCategories($v = true) + { + $this->collAttributeCategoriesPartial = $v; + } + + /** + * Initializes the collAttributeCategories collection. * - * By default this just sets the collAttributeCategorys collection to an empty array (like clearcollAttributeCategorys()); + * By default this just sets the collAttributeCategories collection to an empty array (like clearcollAttributeCategories()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initAttributeCategories($overrideExisting = true) { - if (null !== $this->collAttributeCategorys && !$overrideExisting) { + if (null !== $this->collAttributeCategories && !$overrideExisting) { return; } - $this->collAttributeCategorys = new PropelObjectCollection(); - $this->collAttributeCategorys->setModel('AttributeCategory'); + $this->collAttributeCategories = new ObjectCollection(); + $this->collAttributeCategories->setModel('\Thelia\Model\AttributeCategory'); } /** - * Gets an array of AttributeCategory objects which contain a foreign key that references this object. + * Gets an array of ChildAttributeCategory objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCategory is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects * @throws PropelException */ - public function getAttributeCategorys($criteria = null, PropelPDO $con = null) + public function getAttributeCategories($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategorys) { + $partial = $this->collAttributeCategoriesPartial && !$this->isNew(); + if (null === $this->collAttributeCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeCategories) { // return empty collection - $this->initAttributeCategorys(); + $this->initAttributeCategories(); } else { - $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria) + $collAttributeCategories = ChildAttributeCategoryQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collAttributeCategorysPartial && count($collAttributeCategorys)) { - $this->initAttributeCategorys(false); + if (false !== $this->collAttributeCategoriesPartial && count($collAttributeCategories)) { + $this->initAttributeCategories(false); - foreach($collAttributeCategorys as $obj) { - if (false == $this->collAttributeCategorys->contains($obj)) { - $this->collAttributeCategorys->append($obj); + foreach ($collAttributeCategories as $obj) { + if (false == $this->collAttributeCategories->contains($obj)) { + $this->collAttributeCategories->append($obj); + } } - } - $this->collAttributeCategorysPartial = true; + $this->collAttributeCategoriesPartial = true; } - $collAttributeCategorys->getInternalIterator()->rewind(); - return $collAttributeCategorys; + $collAttributeCategories->getInternalIterator()->rewind(); + + return $collAttributeCategories; } - if($partial && $this->collAttributeCategorys) { - foreach($this->collAttributeCategorys as $obj) { - if($obj->isNew()) { - $collAttributeCategorys[] = $obj; + if ($partial && $this->collAttributeCategories) { + foreach ($this->collAttributeCategories as $obj) { + if ($obj->isNew()) { + $collAttributeCategories[] = $obj; } } } - $this->collAttributeCategorys = $collAttributeCategorys; - $this->collAttributeCategorysPartial = false; + $this->collAttributeCategories = $collAttributeCategories; + $this->collAttributeCategoriesPartial = false; } } - return $this->collAttributeCategorys; + return $this->collAttributeCategories; } /** @@ -2604,27 +2656,28 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $attributeCategories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null) + public function setAttributeCategories(Collection $attributeCategories, ConnectionInterface $con = null) { - $attributeCategorysToDelete = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); + $attributeCategoriesToDelete = $this->getAttributeCategories(new Criteria(), $con)->diff($attributeCategories); - $this->attributeCategorysScheduledForDeletion = unserialize(serialize($attributeCategorysToDelete)); - foreach ($attributeCategorysToDelete as $attributeCategoryRemoved) { + $this->attributeCategoriesScheduledForDeletion = $attributeCategoriesToDelete; + + foreach ($attributeCategoriesToDelete as $attributeCategoryRemoved) { $attributeCategoryRemoved->setCategory(null); } - $this->collAttributeCategorys = null; - foreach ($attributeCategorys as $attributeCategory) { + $this->collAttributeCategories = null; + foreach ($attributeCategories as $attributeCategory) { $this->addAttributeCategory($attributeCategory); } - $this->collAttributeCategorys = $attributeCategorys; - $this->collAttributeCategorysPartial = false; + $this->collAttributeCategories = $attributeCategories; + $this->collAttributeCategoriesPartial = false; return $this; } @@ -2632,24 +2685,25 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the number of related AttributeCategory objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AttributeCategory objects. * @throws PropelException */ - public function countAttributeCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributeCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategorys) { + $partial = $this->collAttributeCategoriesPartial && !$this->isNew(); + if (null === $this->collAttributeCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAttributeCategories) { return 0; } - if($partial && !$criteria) { - return count($this->getAttributeCategorys()); + if ($partial && !$criteria) { + return count($this->getAttributeCategories()); } - $query = AttributeCategoryQuery::create(null, $criteria); + + $query = ChildAttributeCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2659,23 +2713,24 @@ abstract class BaseCategory extends BaseObject implements Persistent ->count($con); } - return count($this->collAttributeCategorys); + return count($this->collAttributeCategories); } /** - * Method called to associate a AttributeCategory object to this object - * through the AttributeCategory foreign key attribute. + * Method called to associate a ChildAttributeCategory object to this object + * through the ChildAttributeCategory foreign key attribute. * - * @param AttributeCategory $l AttributeCategory - * @return Category The current object (for fluent API support) + * @param ChildAttributeCategory $l ChildAttributeCategory + * @return \Thelia\Model\Category The current object (for fluent API support) */ - public function addAttributeCategory(AttributeCategory $l) + public function addAttributeCategory(ChildAttributeCategory $l) { - if ($this->collAttributeCategorys === null) { - $this->initAttributeCategorys(); - $this->collAttributeCategorysPartial = true; + if ($this->collAttributeCategories === null) { + $this->initAttributeCategories(); + $this->collAttributeCategoriesPartial = true; } - if (!in_array($l, $this->collAttributeCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collAttributeCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAttributeCategory($l); } @@ -2683,27 +2738,27 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param AttributeCategory $attributeCategory The attributeCategory object to add. + * @param AttributeCategory $attributeCategory The attributeCategory object to add. */ protected function doAddAttributeCategory($attributeCategory) { - $this->collAttributeCategorys[]= $attributeCategory; + $this->collAttributeCategories[]= $attributeCategory; $attributeCategory->setCategory($this); } /** - * @param AttributeCategory $attributeCategory The attributeCategory object to remove. - * @return Category The current object (for fluent API support) + * @param AttributeCategory $attributeCategory The attributeCategory object to remove. + * @return ChildCategory 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(); + if ($this->getAttributeCategories()->contains($attributeCategory)) { + $this->collAttributeCategories->remove($this->collAttributeCategories->search($attributeCategory)); + if (null === $this->attributeCategoriesScheduledForDeletion) { + $this->attributeCategoriesScheduledForDeletion = clone $this->collAttributeCategories; + $this->attributeCategoriesScheduledForDeletion->clear(); } - $this->attributeCategorysScheduledForDeletion[]= clone $attributeCategory; + $this->attributeCategoriesScheduledForDeletion[]= clone $attributeCategory; $attributeCategory->setCategory(null); } @@ -2716,23 +2771,23 @@ abstract class BaseCategory extends BaseObject implements Persistent * an identical criteria, it returns the collection. * Otherwise if this Category is new, it will return * an empty collection; or if this Category has previously - * been saved, it will retrieve related AttributeCategorys from storage. + * been saved, it will retrieve related AttributeCategories from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAttributeCategory[] List of ChildAttributeCategory objects */ - public function getAttributeCategorysJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAttributeCategoriesJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AttributeCategoryQuery::create(null, $criteria); - $query->joinWith('Attribute', $join_behavior); + $query = ChildAttributeCategoryQuery::create(null, $criteria); + $query->joinWith('Attribute', $joinBehavior); - return $this->getAttributeCategorys($query, $con); + return $this->getAttributeCategories($query, $con); } /** @@ -2741,21 +2796,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * This 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) + * @return void * @see addContentAssocs() */ public function clearContentAssocs() { - $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized - $this->collContentAssocsPartial = null; - - return $this; + $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collContentAssocs collection loaded partially - * - * @return void + * Reset is the collContentAssocs collection loaded partially. */ public function resetPartialContentAssocs($v = true) { @@ -2769,7 +2819,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2779,25 +2829,25 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null !== $this->collContentAssocs && !$overrideExisting) { return; } - $this->collContentAssocs = new PropelObjectCollection(); - $this->collContentAssocs->setModel('ContentAssoc'); + $this->collContentAssocs = new ObjectCollection(); + $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc'); } /** - * Gets an array of ContentAssoc objects which contain a foreign key that references this object. + * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCategory is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects * @throws PropelException */ - public function getContentAssocs($criteria = null, PropelPDO $con = null) + public function getContentAssocs($criteria = null, ConnectionInterface $con = null) { $partial = $this->collContentAssocsPartial && !$this->isNew(); if (null === $this->collContentAssocs || null !== $criteria || $partial) { @@ -2805,29 +2855,31 @@ abstract class BaseCategory extends BaseObject implements Persistent // return empty collection $this->initContentAssocs(); } else { - $collContentAssocs = ContentAssocQuery::create(null, $criteria) + $collContentAssocs = ChildContentAssocQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); + $this->initContentAssocs(false); - foreach($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); + foreach ($collContentAssocs as $obj) { + if (false == $this->collContentAssocs->contains($obj)) { + $this->collContentAssocs->append($obj); + } } - } - $this->collContentAssocsPartial = true; + $this->collContentAssocsPartial = true; } $collContentAssocs->getInternalIterator()->rewind(); + return $collContentAssocs; } - if($partial && $this->collContentAssocs) { - foreach($this->collContentAssocs as $obj) { - if($obj->isNew()) { + if ($partial && $this->collContentAssocs) { + foreach ($this->collContentAssocs as $obj) { + if ($obj->isNew()) { $collContentAssocs[] = $obj; } } @@ -2847,15 +2899,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $contentAssocs A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) + public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null) { $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete)); + + $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete; foreach ($contentAssocsToDelete as $contentAssocRemoved) { $contentAssocRemoved->setCategory(null); @@ -2875,13 +2928,13 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the number of related ContentAssoc objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ContentAssoc objects. * @throws PropelException */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collContentAssocsPartial && !$this->isNew(); if (null === $this->collContentAssocs || null !== $criteria || $partial) { @@ -2889,10 +2942,11 @@ abstract class BaseCategory extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getContentAssocs()); } - $query = ContentAssocQuery::create(null, $criteria); + + $query = ChildContentAssocQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2906,18 +2960,19 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Method called to associate a ContentAssoc object to this object - * through the ContentAssoc foreign key attribute. + * Method called to associate a ChildContentAssoc object to this object + * through the ChildContentAssoc foreign key attribute. * - * @param ContentAssoc $l ContentAssoc - * @return Category The current object (for fluent API support) + * @param ChildContentAssoc $l ChildContentAssoc + * @return \Thelia\Model\Category The current object (for fluent API support) */ - public function addContentAssoc(ContentAssoc $l) + public function addContentAssoc(ChildContentAssoc $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); } @@ -2926,7 +2981,7 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. + * @param ContentAssoc $contentAssoc The contentAssoc object to add. */ protected function doAddContentAssoc($contentAssoc) { @@ -2935,8 +2990,8 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return Category The current object (for fluent API support) + * @param ContentAssoc $contentAssoc The contentAssoc object to remove. + * @return ChildCategory The current object (for fluent API support) */ public function removeContentAssoc($contentAssoc) { @@ -2965,15 +3020,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects */ - public function getContentAssocsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getContentAssocsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildContentAssocQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getContentAssocs($query, $con); } @@ -2990,15 +3045,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects */ - public function getContentAssocsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getContentAssocsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildContentAssocQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getContentAssocs($query, $con); } @@ -3009,21 +3064,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * This 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) + * @return void * @see addImages() */ public function clearImages() { - $this->collImages = null; // important to set this to null since that means it is uninitialized - $this->collImagesPartial = null; - - return $this; + $this->collImages = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collImages collection loaded partially - * - * @return void + * Reset is the collImages collection loaded partially. */ public function resetPartialImages($v = true) { @@ -3037,7 +3087,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3047,25 +3097,25 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null !== $this->collImages && !$overrideExisting) { return; } - $this->collImages = new PropelObjectCollection(); - $this->collImages->setModel('Image'); + $this->collImages = new ObjectCollection(); + $this->collImages->setModel('\Thelia\Model\Image'); } /** - * Gets an array of Image objects which contain a foreign key that references this object. + * Gets an array of ChildImage objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCategory is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildImage[] List of ChildImage objects * @throws PropelException */ - public function getImages($criteria = null, PropelPDO $con = null) + public function getImages($criteria = null, ConnectionInterface $con = null) { $partial = $this->collImagesPartial && !$this->isNew(); if (null === $this->collImages || null !== $criteria || $partial) { @@ -3073,29 +3123,31 @@ abstract class BaseCategory extends BaseObject implements Persistent // return empty collection $this->initImages(); } else { - $collImages = ImageQuery::create(null, $criteria) + $collImages = ChildImageQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); + $this->initImages(false); - foreach($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); + foreach ($collImages as $obj) { + if (false == $this->collImages->contains($obj)) { + $this->collImages->append($obj); + } } - } - $this->collImagesPartial = true; + $this->collImagesPartial = true; } $collImages->getInternalIterator()->rewind(); + return $collImages; } - if($partial && $this->collImages) { - foreach($this->collImages as $obj) { - if($obj->isNew()) { + if ($partial && $this->collImages) { + foreach ($this->collImages as $obj) { + if ($obj->isNew()) { $collImages[] = $obj; } } @@ -3115,15 +3167,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $images A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setImages(PropelCollection $images, PropelPDO $con = null) + public function setImages(Collection $images, ConnectionInterface $con = null) { $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); + + $this->imagesScheduledForDeletion = $imagesToDelete; foreach ($imagesToDelete as $imageRemoved) { $imageRemoved->setCategory(null); @@ -3143,13 +3196,13 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the number of related Image objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Image objects. * @throws PropelException */ - public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collImagesPartial && !$this->isNew(); if (null === $this->collImages || null !== $criteria || $partial) { @@ -3157,10 +3210,11 @@ abstract class BaseCategory extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getImages()); } - $query = ImageQuery::create(null, $criteria); + + $query = ChildImageQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3174,18 +3228,19 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Method called to associate a Image object to this object - * through the Image foreign key attribute. + * Method called to associate a ChildImage object to this object + * through the ChildImage foreign key attribute. * - * @param Image $l Image - * @return Category The current object (for fluent API support) + * @param ChildImage $l ChildImage + * @return \Thelia\Model\Category The current object (for fluent API support) */ - public function addImage(Image $l) + public function addImage(ChildImage $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); } @@ -3194,7 +3249,7 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param Image $image The image object to add. + * @param Image $image The image object to add. */ protected function doAddImage($image) { @@ -3203,8 +3258,8 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param Image $image The image object to remove. - * @return Category The current object (for fluent API support) + * @param Image $image The image object to remove. + * @return ChildCategory The current object (for fluent API support) */ public function removeImage($image) { @@ -3233,15 +3288,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getImages($query, $con); } @@ -3258,15 +3313,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getImages($query, $con); } @@ -3283,15 +3338,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getImages($query, $con); } @@ -3302,21 +3357,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * This 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) + * @return void * @see addDocuments() */ public function clearDocuments() { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - - return $this; + $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collDocuments collection loaded partially - * - * @return void + * Reset is the collDocuments collection loaded partially. */ public function resetPartialDocuments($v = true) { @@ -3330,7 +3380,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3340,25 +3390,25 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null !== $this->collDocuments && !$overrideExisting) { return; } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); + $this->collDocuments = new ObjectCollection(); + $this->collDocuments->setModel('\Thelia\Model\Document'); } /** - * Gets an array of Document objects which contain a foreign key that references this object. + * Gets an array of ChildDocument objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCategory is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildDocument[] List of ChildDocument objects * @throws PropelException */ - public function getDocuments($criteria = null, PropelPDO $con = null) + public function getDocuments($criteria = null, ConnectionInterface $con = null) { $partial = $this->collDocumentsPartial && !$this->isNew(); if (null === $this->collDocuments || null !== $criteria || $partial) { @@ -3366,29 +3416,31 @@ abstract class BaseCategory extends BaseObject implements Persistent // return empty collection $this->initDocuments(); } else { - $collDocuments = DocumentQuery::create(null, $criteria) + $collDocuments = ChildDocumentQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); + $this->initDocuments(false); - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); + foreach ($collDocuments as $obj) { + if (false == $this->collDocuments->contains($obj)) { + $this->collDocuments->append($obj); + } } - } - $this->collDocumentsPartial = true; + $this->collDocumentsPartial = true; } $collDocuments->getInternalIterator()->rewind(); + return $collDocuments; } - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { + if ($partial && $this->collDocuments) { + foreach ($this->collDocuments as $obj) { + if ($obj->isNew()) { $collDocuments[] = $obj; } } @@ -3408,15 +3460,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $documents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) + public function setDocuments(Collection $documents, ConnectionInterface $con = null) { $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); + + $this->documentsScheduledForDeletion = $documentsToDelete; foreach ($documentsToDelete as $documentRemoved) { $documentRemoved->setCategory(null); @@ -3436,13 +3489,13 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the number of related Document objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Document objects. * @throws PropelException */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collDocumentsPartial && !$this->isNew(); if (null === $this->collDocuments || null !== $criteria || $partial) { @@ -3450,10 +3503,11 @@ abstract class BaseCategory extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getDocuments()); } - $query = DocumentQuery::create(null, $criteria); + + $query = ChildDocumentQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3467,18 +3521,19 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. + * Method called to associate a ChildDocument object to this object + * through the ChildDocument foreign key attribute. * - * @param Document $l Document - * @return Category The current object (for fluent API support) + * @param ChildDocument $l ChildDocument + * @return \Thelia\Model\Category The current object (for fluent API support) */ - public function addDocument(Document $l) + public function addDocument(ChildDocument $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); } @@ -3487,7 +3542,7 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param Document $document The document object to add. + * @param Document $document The document object to add. */ protected function doAddDocument($document) { @@ -3496,8 +3551,8 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param Document $document The document object to remove. - * @return Category The current object (for fluent API support) + * @param Document $document The document object to remove. + * @return ChildCategory The current object (for fluent API support) */ public function removeDocument($document) { @@ -3526,15 +3581,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getDocuments($query, $con); } @@ -3551,15 +3606,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getDocuments($query, $con); } @@ -3576,15 +3631,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getDocuments($query, $con); } @@ -3595,21 +3650,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * This 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) + * @return void * @see addRewritings() */ public function clearRewritings() { - $this->collRewritings = null; // important to set this to null since that means it is uninitialized - $this->collRewritingsPartial = null; - - return $this; + $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collRewritings collection loaded partially - * - * @return void + * Reset is the collRewritings collection loaded partially. */ public function resetPartialRewritings($v = true) { @@ -3623,7 +3673,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3633,25 +3683,25 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null !== $this->collRewritings && !$overrideExisting) { return; } - $this->collRewritings = new PropelObjectCollection(); - $this->collRewritings->setModel('Rewriting'); + $this->collRewritings = new ObjectCollection(); + $this->collRewritings->setModel('\Thelia\Model\Rewriting'); } /** - * Gets an array of Rewriting objects which contain a foreign key that references this object. + * Gets an array of ChildRewriting objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCategory is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildRewriting[] List of ChildRewriting objects * @throws PropelException */ - public function getRewritings($criteria = null, PropelPDO $con = null) + public function getRewritings($criteria = null, ConnectionInterface $con = null) { $partial = $this->collRewritingsPartial && !$this->isNew(); if (null === $this->collRewritings || null !== $criteria || $partial) { @@ -3659,29 +3709,31 @@ abstract class BaseCategory extends BaseObject implements Persistent // return empty collection $this->initRewritings(); } else { - $collRewritings = RewritingQuery::create(null, $criteria) + $collRewritings = ChildRewritingQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); + $this->initRewritings(false); - foreach($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); + foreach ($collRewritings as $obj) { + if (false == $this->collRewritings->contains($obj)) { + $this->collRewritings->append($obj); + } } - } - $this->collRewritingsPartial = true; + $this->collRewritingsPartial = true; } $collRewritings->getInternalIterator()->rewind(); + return $collRewritings; } - if($partial && $this->collRewritings) { - foreach($this->collRewritings as $obj) { - if($obj->isNew()) { + if ($partial && $this->collRewritings) { + foreach ($this->collRewritings as $obj) { + if ($obj->isNew()) { $collRewritings[] = $obj; } } @@ -3701,15 +3753,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $rewritings A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) + public function setRewritings(Collection $rewritings, ConnectionInterface $con = null) { $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); + + $this->rewritingsScheduledForDeletion = $rewritingsToDelete; foreach ($rewritingsToDelete as $rewritingRemoved) { $rewritingRemoved->setCategory(null); @@ -3729,13 +3782,13 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the number of related Rewriting objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Rewriting objects. * @throws PropelException */ - public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRewritingsPartial && !$this->isNew(); if (null === $this->collRewritings || null !== $criteria || $partial) { @@ -3743,10 +3796,11 @@ abstract class BaseCategory extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getRewritings()); } - $query = RewritingQuery::create(null, $criteria); + + $query = ChildRewritingQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3760,18 +3814,19 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Method called to associate a Rewriting object to this object - * through the Rewriting foreign key attribute. + * Method called to associate a ChildRewriting object to this object + * through the ChildRewriting foreign key attribute. * - * @param Rewriting $l Rewriting - * @return Category The current object (for fluent API support) + * @param ChildRewriting $l ChildRewriting + * @return \Thelia\Model\Category The current object (for fluent API support) */ - public function addRewriting(Rewriting $l) + public function addRewriting(ChildRewriting $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); } @@ -3780,7 +3835,7 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param Rewriting $rewriting The rewriting object to add. + * @param Rewriting $rewriting The rewriting object to add. */ protected function doAddRewriting($rewriting) { @@ -3789,8 +3844,8 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return Category The current object (for fluent API support) + * @param Rewriting $rewriting The rewriting object to remove. + * @return ChildCategory The current object (for fluent API support) */ public function removeRewriting($rewriting) { @@ -3819,15 +3874,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getRewritings($query, $con); } @@ -3844,15 +3899,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getRewritings($query, $con); } @@ -3869,15 +3924,15 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getRewritings($query, $con); } @@ -3888,21 +3943,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collCategoryI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collCategoryI18ns collection loaded partially - * - * @return void + * Reset is the collCategoryI18ns collection loaded partially. */ public function resetPartialCategoryI18ns($v = true) { @@ -3916,7 +3966,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3926,25 +3976,25 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null !== $this->collCategoryI18ns && !$overrideExisting) { return; } - $this->collCategoryI18ns = new PropelObjectCollection(); - $this->collCategoryI18ns->setModel('CategoryI18n'); + $this->collCategoryI18ns = new ObjectCollection(); + $this->collCategoryI18ns->setModel('\Thelia\Model\CategoryI18n'); } /** - * Gets an array of CategoryI18n objects which contain a foreign key that references this object. + * Gets an array of ChildCategoryI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCategory is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryI18n[] List of ChildCategoryI18n objects * @throws PropelException */ - public function getCategoryI18ns($criteria = null, PropelPDO $con = null) + public function getCategoryI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collCategoryI18nsPartial && !$this->isNew(); if (null === $this->collCategoryI18ns || null !== $criteria || $partial) { @@ -3952,29 +4002,31 @@ abstract class BaseCategory extends BaseObject implements Persistent // return empty collection $this->initCategoryI18ns(); } else { - $collCategoryI18ns = CategoryI18nQuery::create(null, $criteria) + $collCategoryI18ns = ChildCategoryI18nQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collCategoryI18nsPartial && count($collCategoryI18ns)) { - $this->initCategoryI18ns(false); + $this->initCategoryI18ns(false); - foreach($collCategoryI18ns as $obj) { - if (false == $this->collCategoryI18ns->contains($obj)) { - $this->collCategoryI18ns->append($obj); + foreach ($collCategoryI18ns as $obj) { + if (false == $this->collCategoryI18ns->contains($obj)) { + $this->collCategoryI18ns->append($obj); + } } - } - $this->collCategoryI18nsPartial = true; + $this->collCategoryI18nsPartial = true; } $collCategoryI18ns->getInternalIterator()->rewind(); + return $collCategoryI18ns; } - if($partial && $this->collCategoryI18ns) { - foreach($this->collCategoryI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collCategoryI18ns) { + foreach ($this->collCategoryI18ns as $obj) { + if ($obj->isNew()) { $collCategoryI18ns[] = $obj; } } @@ -3994,15 +4046,19 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $categoryI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setCategoryI18ns(PropelCollection $categoryI18ns, PropelPDO $con = null) + public function setCategoryI18ns(Collection $categoryI18ns, ConnectionInterface $con = null) { $categoryI18nsToDelete = $this->getCategoryI18ns(new Criteria(), $con)->diff($categoryI18ns); - $this->categoryI18nsScheduledForDeletion = unserialize(serialize($categoryI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->categoryI18nsScheduledForDeletion = clone $categoryI18nsToDelete; foreach ($categoryI18nsToDelete as $categoryI18nRemoved) { $categoryI18nRemoved->setCategory(null); @@ -4022,13 +4078,13 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the number of related CategoryI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related CategoryI18n objects. * @throws PropelException */ - public function countCategoryI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countCategoryI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collCategoryI18nsPartial && !$this->isNew(); if (null === $this->collCategoryI18ns || null !== $criteria || $partial) { @@ -4036,10 +4092,11 @@ abstract class BaseCategory extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getCategoryI18ns()); } - $query = CategoryI18nQuery::create(null, $criteria); + + $query = ChildCategoryI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -4053,13 +4110,13 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Method called to associate a CategoryI18n object to this object - * through the CategoryI18n foreign key attribute. + * Method called to associate a ChildCategoryI18n object to this object + * through the ChildCategoryI18n foreign key attribute. * - * @param CategoryI18n $l CategoryI18n - * @return Category The current object (for fluent API support) + * @param ChildCategoryI18n $l ChildCategoryI18n + * @return \Thelia\Model\Category The current object (for fluent API support) */ - public function addCategoryI18n(CategoryI18n $l) + public function addCategoryI18n(ChildCategoryI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -4069,6 +4126,7 @@ abstract class BaseCategory extends BaseObject implements Persistent $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); } @@ -4077,7 +4135,7 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param CategoryI18n $categoryI18n The categoryI18n object to add. + * @param CategoryI18n $categoryI18n The categoryI18n object to add. */ protected function doAddCategoryI18n($categoryI18n) { @@ -4086,8 +4144,8 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param CategoryI18n $categoryI18n The categoryI18n object to remove. - * @return Category The current object (for fluent API support) + * @param CategoryI18n $categoryI18n The categoryI18n object to remove. + * @return ChildCategory The current object (for fluent API support) */ public function removeCategoryI18n($categoryI18n) { @@ -4110,21 +4168,16 @@ abstract class BaseCategory extends BaseObject implements Persistent * This 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) + * @return void * @see addCategoryVersions() */ public function clearCategoryVersions() { - $this->collCategoryVersions = null; // important to set this to null since that means it is uninitialized - $this->collCategoryVersionsPartial = null; - - return $this; + $this->collCategoryVersions = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collCategoryVersions collection loaded partially - * - * @return void + * Reset is the collCategoryVersions collection loaded partially. */ public function resetPartialCategoryVersions($v = true) { @@ -4138,7 +4191,7 @@ abstract class BaseCategory extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -4148,25 +4201,25 @@ abstract class BaseCategory extends BaseObject implements Persistent if (null !== $this->collCategoryVersions && !$overrideExisting) { return; } - $this->collCategoryVersions = new PropelObjectCollection(); - $this->collCategoryVersions->setModel('CategoryVersion'); + $this->collCategoryVersions = new ObjectCollection(); + $this->collCategoryVersions->setModel('\Thelia\Model\CategoryVersion'); } /** - * Gets an array of CategoryVersion objects which contain a foreign key that references this object. + * Gets an array of ChildCategoryVersion objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCategory is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCategoryVersion[] List of ChildCategoryVersion objects * @throws PropelException */ - public function getCategoryVersions($criteria = null, PropelPDO $con = null) + public function getCategoryVersions($criteria = null, ConnectionInterface $con = null) { $partial = $this->collCategoryVersionsPartial && !$this->isNew(); if (null === $this->collCategoryVersions || null !== $criteria || $partial) { @@ -4174,29 +4227,31 @@ abstract class BaseCategory extends BaseObject implements Persistent // return empty collection $this->initCategoryVersions(); } else { - $collCategoryVersions = CategoryVersionQuery::create(null, $criteria) + $collCategoryVersions = ChildCategoryVersionQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collCategoryVersionsPartial && count($collCategoryVersions)) { - $this->initCategoryVersions(false); + $this->initCategoryVersions(false); - foreach($collCategoryVersions as $obj) { - if (false == $this->collCategoryVersions->contains($obj)) { - $this->collCategoryVersions->append($obj); + foreach ($collCategoryVersions as $obj) { + if (false == $this->collCategoryVersions->contains($obj)) { + $this->collCategoryVersions->append($obj); + } } - } - $this->collCategoryVersionsPartial = true; + $this->collCategoryVersionsPartial = true; } $collCategoryVersions->getInternalIterator()->rewind(); + return $collCategoryVersions; } - if($partial && $this->collCategoryVersions) { - foreach($this->collCategoryVersions as $obj) { - if($obj->isNew()) { + if ($partial && $this->collCategoryVersions) { + foreach ($this->collCategoryVersions as $obj) { + if ($obj->isNew()) { $collCategoryVersions[] = $obj; } } @@ -4216,15 +4271,19 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $categoryVersions A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setCategoryVersions(PropelCollection $categoryVersions, PropelPDO $con = null) + public function setCategoryVersions(Collection $categoryVersions, ConnectionInterface $con = null) { $categoryVersionsToDelete = $this->getCategoryVersions(new Criteria(), $con)->diff($categoryVersions); - $this->categoryVersionsScheduledForDeletion = unserialize(serialize($categoryVersionsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->categoryVersionsScheduledForDeletion = clone $categoryVersionsToDelete; foreach ($categoryVersionsToDelete as $categoryVersionRemoved) { $categoryVersionRemoved->setCategory(null); @@ -4244,13 +4303,13 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the number of related CategoryVersion objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related CategoryVersion objects. * @throws PropelException */ - public function countCategoryVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countCategoryVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collCategoryVersionsPartial && !$this->isNew(); if (null === $this->collCategoryVersions || null !== $criteria || $partial) { @@ -4258,10 +4317,11 @@ abstract class BaseCategory extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getCategoryVersions()); } - $query = CategoryVersionQuery::create(null, $criteria); + + $query = ChildCategoryVersionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -4275,18 +4335,19 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Method called to associate a CategoryVersion object to this object - * through the CategoryVersion foreign key attribute. + * Method called to associate a ChildCategoryVersion object to this object + * through the ChildCategoryVersion foreign key attribute. * - * @param CategoryVersion $l CategoryVersion - * @return Category The current object (for fluent API support) + * @param ChildCategoryVersion $l ChildCategoryVersion + * @return \Thelia\Model\Category The current object (for fluent API support) */ - public function addCategoryVersion(CategoryVersion $l) + public function addCategoryVersion(ChildCategoryVersion $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); } @@ -4295,7 +4356,7 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param CategoryVersion $categoryVersion The categoryVersion object to add. + * @param CategoryVersion $categoryVersion The categoryVersion object to add. */ protected function doAddCategoryVersion($categoryVersion) { @@ -4304,8 +4365,8 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * @param CategoryVersion $categoryVersion The categoryVersion object to remove. - * @return Category The current object (for fluent API support) + * @param CategoryVersion $categoryVersion The categoryVersion object to remove. + * @return ChildCategory The current object (for fluent API support) */ public function removeCategoryVersion($categoryVersion) { @@ -4328,15 +4389,13 @@ abstract class BaseCategory extends BaseObject implements Persistent * This 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) + * @return void * @see addProducts() */ public function clearProducts() { - $this->collProducts = null; // important to set this to null since that means it is uninitialized + $this->collProducts = null; // important to set this to NULL since that means it is uninitialized $this->collProductsPartial = null; - - return $this; } /** @@ -4350,33 +4409,33 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function initProducts() { - $this->collProducts = new PropelObjectCollection(); - $this->collProducts->setModel('Product'); + $this->collProducts = new ObjectCollection(); + $this->collProducts->setModel('\Thelia\Model\Product'); } /** - * Gets a collection of Product objects related by a many-to-many relationship + * Gets a collection of ChildProduct 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 + * If this ChildCategory 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Product[] List of Product objects + * @return ObjectCollection|ChildProduct[] List of ChildProduct objects */ - public function getProducts($criteria = null, PropelPDO $con = null) + public function getProducts($criteria = null, ConnectionInterface $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) + $collProducts = ChildProductQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); if (null !== $criteria) { @@ -4395,11 +4454,11 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $products A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setProducts(PropelCollection $products, PropelPDO $con = null) + public function setProducts(Collection $products, ConnectionInterface $con = null) { $this->clearProducts(); $currentProducts = $this->getProducts(); @@ -4418,22 +4477,22 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Gets the number of Product objects related by a many-to-many relationship + * Gets the number of ChildProduct 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Product objects + * @return int the number of related ChildProduct objects */ - public function countProducts($criteria = null, $distinct = false, PropelPDO $con = null) + public function countProducts($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collProducts || null !== $criteria) { if ($this->isNew() && null === $this->collProducts) { return 0; } else { - $query = ProductQuery::create(null, $criteria); + $query = ChildProductQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -4448,52 +4507,60 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Associate a Product object to this object + * Associate a ChildProduct 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) + * @param ChildProduct $product The ChildProductCategory object to relate + * @return ChildCategory The current object (for fluent API support) */ - public function addProduct(Product $product) + public function addProduct(ChildProduct $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; + $this->collProducts[] = $product; } return $this; } /** - * @param Product $product The product object to add. + * @param Product $product The product object to add. */ protected function doAddProduct($product) { - $productCategory = new ProductCategory(); + $productCategory = new ChildProductCategory(); $productCategory->setProduct($product); $this->addProductCategory($productCategory); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$product->getCategories()->contains($this)) { + $foreignCollection = $product->getCategories(); + $foreignCollection[] = $this; + } } /** - * Remove a Product object to this object + * Remove a ChildProduct 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) + * @param ChildProduct $product The ChildProductCategory object to relate + * @return ChildCategory The current object (for fluent API support) */ - public function removeProduct(Product $product) + public function removeProduct(ChildProduct $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; + + $this->productsScheduledForDeletion[] = $product; } return $this; @@ -4505,15 +4572,13 @@ abstract class BaseCategory extends BaseObject implements Persistent * This 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) + * @return void * @see addFeatures() */ public function clearFeatures() { - $this->collFeatures = null; // important to set this to null since that means it is uninitialized + $this->collFeatures = null; // important to set this to NULL since that means it is uninitialized $this->collFeaturesPartial = null; - - return $this; } /** @@ -4527,33 +4592,33 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function initFeatures() { - $this->collFeatures = new PropelObjectCollection(); - $this->collFeatures->setModel('Feature'); + $this->collFeatures = new ObjectCollection(); + $this->collFeatures->setModel('\Thelia\Model\Feature'); } /** - * Gets a collection of Feature objects related by a many-to-many relationship + * Gets a collection of ChildFeature 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 + * If this ChildCategory 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Feature[] List of Feature objects + * @return ObjectCollection|ChildFeature[] List of ChildFeature objects */ - public function getFeatures($criteria = null, PropelPDO $con = null) + public function getFeatures($criteria = null, ConnectionInterface $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) + $collFeatures = ChildFeatureQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); if (null !== $criteria) { @@ -4572,11 +4637,11 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $features A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setFeatures(PropelCollection $features, PropelPDO $con = null) + public function setFeatures(Collection $features, ConnectionInterface $con = null) { $this->clearFeatures(); $currentFeatures = $this->getFeatures(); @@ -4595,22 +4660,22 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Gets the number of Feature objects related by a many-to-many relationship + * Gets the number of ChildFeature 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Feature objects + * @return int the number of related ChildFeature objects */ - public function countFeatures($criteria = null, $distinct = false, PropelPDO $con = null) + public function countFeatures($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collFeatures || null !== $criteria) { if ($this->isNew() && null === $this->collFeatures) { return 0; } else { - $query = FeatureQuery::create(null, $criteria); + $query = ChildFeatureQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -4625,52 +4690,60 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Associate a Feature object to this object + * Associate a ChildFeature 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) + * @param ChildFeature $feature The ChildFeatureCategory object to relate + * @return ChildCategory The current object (for fluent API support) */ - public function addFeature(Feature $feature) + public function addFeature(ChildFeature $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; + $this->collFeatures[] = $feature; } return $this; } /** - * @param Feature $feature The feature object to add. + * @param Feature $feature The feature object to add. */ protected function doAddFeature($feature) { - $featureCategory = new FeatureCategory(); + $featureCategory = new ChildFeatureCategory(); $featureCategory->setFeature($feature); $this->addFeatureCategory($featureCategory); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$feature->getCategories()->contains($this)) { + $foreignCollection = $feature->getCategories(); + $foreignCollection[] = $this; + } } /** - * Remove a Feature object to this object + * Remove a ChildFeature 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) + * @param ChildFeature $feature The ChildFeatureCategory object to relate + * @return ChildCategory The current object (for fluent API support) */ - public function removeFeature(Feature $feature) + public function removeFeature(ChildFeature $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; + + $this->featuresScheduledForDeletion[] = $feature; } return $this; @@ -4682,15 +4755,13 @@ abstract class BaseCategory extends BaseObject implements Persistent * This 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) + * @return void * @see addAttributes() */ public function clearAttributes() { - $this->collAttributes = null; // important to set this to null since that means it is uninitialized + $this->collAttributes = null; // important to set this to NULL since that means it is uninitialized $this->collAttributesPartial = null; - - return $this; } /** @@ -4704,33 +4775,33 @@ abstract class BaseCategory extends BaseObject implements Persistent */ public function initAttributes() { - $this->collAttributes = new PropelObjectCollection(); - $this->collAttributes->setModel('Attribute'); + $this->collAttributes = new ObjectCollection(); + $this->collAttributes->setModel('\Thelia\Model\Attribute'); } /** - * Gets a collection of Attribute objects related by a many-to-many relationship + * Gets a collection of ChildAttribute 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 + * If this ChildCategory 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Attribute[] List of Attribute objects + * @return ObjectCollection|ChildAttribute[] List of ChildAttribute objects */ - public function getAttributes($criteria = null, PropelPDO $con = null) + public function getAttributes($criteria = null, ConnectionInterface $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) + $collAttributes = ChildAttributeQuery::create(null, $criteria) ->filterByCategory($this) ->find($con); if (null !== $criteria) { @@ -4749,11 +4820,11 @@ abstract class BaseCategory extends BaseObject implements Persistent * It will 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) + * @param Collection $attributes A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCategory The current object (for fluent API support) */ - public function setAttributes(PropelCollection $attributes, PropelPDO $con = null) + public function setAttributes(Collection $attributes, ConnectionInterface $con = null) { $this->clearAttributes(); $currentAttributes = $this->getAttributes(); @@ -4772,22 +4843,22 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Gets the number of Attribute objects related by a many-to-many relationship + * Gets the number of ChildAttribute 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Attribute objects + * @return int the number of related ChildAttribute objects */ - public function countAttributes($criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributes($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collAttributes || null !== $criteria) { if ($this->isNew() && null === $this->collAttributes) { return 0; } else { - $query = AttributeQuery::create(null, $criteria); + $query = ChildAttributeQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -4802,52 +4873,60 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Associate a Attribute object to this object + * Associate a ChildAttribute 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) + * @param ChildAttribute $attribute The ChildAttributeCategory object to relate + * @return ChildCategory The current object (for fluent API support) */ - public function addAttribute(Attribute $attribute) + public function addAttribute(ChildAttribute $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; + $this->collAttributes[] = $attribute; } return $this; } /** - * @param Attribute $attribute The attribute object to add. + * @param Attribute $attribute The attribute object to add. */ protected function doAddAttribute($attribute) { - $attributeCategory = new AttributeCategory(); + $attributeCategory = new ChildAttributeCategory(); $attributeCategory->setAttribute($attribute); $this->addAttributeCategory($attributeCategory); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$attribute->getCategories()->contains($this)) { + $foreignCollection = $attribute->getCategories(); + $foreignCollection[] = $this; + } } /** - * Remove a Attribute object to this object + * Remove a ChildAttribute 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) + * @param ChildAttribute $attribute The ChildAttributeCategory object to relate + * @return ChildCategory The current object (for fluent API support) */ - public function removeAttribute(Attribute $attribute) + public function removeAttribute(ChildAttribute $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; + + $this->attributesScheduledForDeletion[] = $attribute; } return $this; @@ -4869,8 +4948,6 @@ abstract class BaseCategory extends BaseObject implements Persistent $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(); @@ -4883,26 +4960,25 @@ abstract class BaseCategory extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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) { + if ($deep) { + if ($this->collProductCategories) { + foreach ($this->collProductCategories as $o) { $o->clearAllReferences($deep); } } - if ($this->collFeatureCategorys) { - foreach ($this->collFeatureCategorys as $o) { + if ($this->collFeatureCategories) { + foreach ($this->collFeatureCategories as $o) { $o->clearAllReferences($deep); } } - if ($this->collAttributeCategorys) { - foreach ($this->collAttributeCategorys as $o) { + if ($this->collAttributeCategories) { + foreach ($this->collAttributeCategories as $o) { $o->clearAllReferences($deep); } } @@ -4951,82 +5027,70 @@ abstract class BaseCategory extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collProductCategorys instanceof PropelCollection) { - $this->collProductCategorys->clearIterator(); + if ($this->collProductCategories instanceof Collection) { + $this->collProductCategories->clearIterator(); } - $this->collProductCategorys = null; - if ($this->collFeatureCategorys instanceof PropelCollection) { - $this->collFeatureCategorys->clearIterator(); + $this->collProductCategories = null; + if ($this->collFeatureCategories instanceof Collection) { + $this->collFeatureCategories->clearIterator(); } - $this->collFeatureCategorys = null; - if ($this->collAttributeCategorys instanceof PropelCollection) { - $this->collAttributeCategorys->clearIterator(); + $this->collFeatureCategories = null; + if ($this->collAttributeCategories instanceof Collection) { + $this->collAttributeCategories->clearIterator(); } - $this->collAttributeCategorys = null; - if ($this->collContentAssocs instanceof PropelCollection) { + $this->collAttributeCategories = null; + if ($this->collContentAssocs instanceof Collection) { $this->collContentAssocs->clearIterator(); } $this->collContentAssocs = null; - if ($this->collImages instanceof PropelCollection) { + if ($this->collImages instanceof Collection) { $this->collImages->clearIterator(); } $this->collImages = null; - if ($this->collDocuments instanceof PropelCollection) { + if ($this->collDocuments instanceof Collection) { $this->collDocuments->clearIterator(); } $this->collDocuments = null; - if ($this->collRewritings instanceof PropelCollection) { + if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } $this->collRewritings = null; - if ($this->collCategoryI18ns instanceof PropelCollection) { + if ($this->collCategoryI18ns instanceof Collection) { $this->collCategoryI18ns->clearIterator(); } $this->collCategoryI18ns = null; - if ($this->collCategoryVersions instanceof PropelCollection) { + if ($this->collCategoryVersions instanceof Collection) { $this->collCategoryVersions->clearIterator(); } $this->collCategoryVersions = null; - if ($this->collProducts instanceof PropelCollection) { + if ($this->collProducts instanceof Collection) { $this->collProducts->clearIterator(); } $this->collProducts = null; - if ($this->collFeatures instanceof PropelCollection) { + if ($this->collFeatures instanceof Collection) { $this->collFeatures->clearIterator(); } $this->collFeatures = null; - if ($this->collAttributes instanceof PropelCollection) { + if ($this->collAttributes instanceof Collection) { $this->collAttributes->clearIterator(); } $this->collAttributes = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(CategoryTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -5034,11 +5098,11 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * 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) + * @return ChildCategory The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = CategoryPeer::UPDATED_AT; + $this->modifiedColumns[] = CategoryTableMap::UPDATED_AT; return $this; } @@ -5050,9 +5114,9 @@ abstract class BaseCategory extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Category The current object (for fluent API support) + * @return ChildCategory The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -5073,10 +5137,10 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return CategoryI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildCategoryI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCategoryI18ns) { @@ -5089,10 +5153,10 @@ abstract class BaseCategory extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new CategoryI18n(); + $translation = new ChildCategoryI18n(); $translation->setLocale($locale); } else { - $translation = CategoryI18nQuery::create() + $translation = ChildCategoryI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -5107,14 +5171,14 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Category The current object (for fluent API support) + * @return ChildCategory The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - CategoryI18nQuery::create() + ChildCategoryI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -5134,10 +5198,10 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return CategoryI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildCategoryI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -5146,7 +5210,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -5157,8 +5221,8 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -5170,7 +5234,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -5181,8 +5245,8 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -5194,7 +5258,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -5205,8 +5269,8 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -5218,7 +5282,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -5229,8 +5293,8 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -5243,7 +5307,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Enforce a new Version of this object upon next save. * - * @return Category + * @return \Thelia\Model\Category */ public function enforceVersioning() { @@ -5255,8 +5319,6 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * 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) @@ -5269,7 +5331,7 @@ abstract class BaseCategory extends BaseObject implements Persistent return true; } - if (CategoryPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) { + if (ChildCategoryQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) { return true; } @@ -5279,15 +5341,15 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Creates a version of the current object and saves it. * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return CategoryVersion A version object + * @return ChildCategoryVersion A version object */ public function addVersion($con = null) { $this->enforceVersion = false; - $version = new CategoryVersion(); + $version = new ChildCategoryVersion(); $version->setId($this->getId()); $version->setParent($this->getParent()); $version->setLink($this->getLink()); @@ -5305,19 +5367,18 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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 + * @param ConnectionInterface $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. + * @return ChildCategory The current object (for fluent API support) */ 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)); + throw new PropelException(sprintf('No ChildCategory object found with version %d', $version)); } $this->populateFromVersion($version, $con); @@ -5325,18 +5386,17 @@ abstract class BaseCategory extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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. + * @param ChildCategoryVersion $version The version object to use + * @param ConnectionInterface $con the connection to use + * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects. * - * @return Category The current object (for fluent API support) + * @return ChildCategory The current object (for fluent API support) */ public function populateFromVersion($version, $con = null, &$loadedObjects = array()) { - - $loadedObjects['Category'][$version->getId()][$version->getVersion()] = $this; + $loadedObjects['ChildCategory'][$version->getId()][$version->getVersion()] = $this; $this->setId($version->getId()); $this->setParent($version->getParent()); $this->setLink($version->getLink()); @@ -5354,13 +5414,13 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Gets the latest persisted version number for the current object * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * * @return integer */ public function getLastVersionNumber($con = null) { - $v = CategoryVersionQuery::create() + $v = ChildCategoryVersionQuery::create() ->filterByCategory($this) ->orderByVersion('desc') ->findOne($con); @@ -5374,9 +5434,9 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Checks whether the current object is the latest one * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return boolean + * @return Boolean */ public function isLastVersion($con = null) { @@ -5387,13 +5447,13 @@ abstract class BaseCategory extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con the connection to use * - * @return CategoryVersion A version object + * @return ChildCategoryVersion A version object */ public function getOneVersion($versionNumber, $con = null) { - return CategoryVersionQuery::create() + return ChildCategoryVersionQuery::create() ->filterByCategory($this) ->filterByVersion($versionNumber) ->findOne($con); @@ -5402,14 +5462,14 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Gets all the versions of this object, in incremental order * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return PropelObjectCollection A list of CategoryVersion objects + * @return ObjectCollection A list of ChildCategoryVersion objects */ public function getAllVersions($con = null) { $criteria = new Criteria(); - $criteria->addAscendingOrderByColumn(CategoryVersionPeer::VERSION); + $criteria->addAscendingOrderByColumn(CategoryVersionTableMap::VERSION); return $this->getCategoryVersions($criteria, $con); } @@ -5424,10 +5484,10 @@ abstract class BaseCategory extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $versionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -5449,11 +5509,11 @@ abstract class BaseCategory extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $fromVersionNumber + * @param integer $toVersionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -5468,7 +5528,7 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * Computes the diff between two versions. * - * print_r($this->computeDiff(1, 2)); + * print_r($book->computeDiff(1, 2)); * => array( * '1' => array('Title' => 'Book title at version 1'), * '2' => array('Title' => 'Book title at version 2') @@ -5517,18 +5577,133 @@ abstract class BaseCategory extends BaseObject implements Persistent /** * 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 + * @param Integer $number the number of record to return. + * @return PropelCollection|array \Thelia\Model\CategoryVersion[] List of \Thelia\Model\CategoryVersion objects */ - public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null) + public function getLastVersions($number = 10, $criteria = null, $con = null) { - $criteria = CategoryVersionQuery::create(null, $criteria); - $criteria->addDescendingOrderByColumn(CategoryVersionPeer::VERSION); + $criteria = ChildCategoryVersionQuery::create(null, $criteria); + $criteria->addDescendingOrderByColumn(CategoryVersionTableMap::VERSION); $criteria->limit($number); return $this->getCategoryVersions($criteria, $con); } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/CategoryI18n.php b/core/lib/Thelia/Model/Base/CategoryI18n.php new file mode 100644 index 000000000..65fa17063 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\CategoryI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CategoryI18n instance. If + * obj is an instance of CategoryI18n, delegates to + * equals(CategoryI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CategoryI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CategoryI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CategoryI18nTableMap::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 \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = CategoryI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = CategoryI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CategoryI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = CategoryI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = CategoryI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = CategoryI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CategoryI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(CategoryI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCategoryI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCategory = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CategoryI18n::setDeleted() + * @see CategoryI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCategoryI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME); + } + + $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); + CategoryI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CategoryI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CategoryI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(CategoryI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(CategoryI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(CategoryI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(CategoryI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CategoryI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CategoryI18n'][serialize($this->getPrimaryKey())] = true; + $keys = CategoryI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = CategoryI18nTableMap::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(CategoryI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CategoryI18nTableMap::ID)) $criteria->add(CategoryI18nTableMap::ID, $this->id); + if ($this->isColumnModified(CategoryI18nTableMap::LOCALE)) $criteria->add(CategoryI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(CategoryI18nTableMap::TITLE)) $criteria->add(CategoryI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(CategoryI18nTableMap::DESCRIPTION)) $criteria->add(CategoryI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(CategoryI18nTableMap::CHAPO)) $criteria->add(CategoryI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(CategoryI18nTableMap::POSTSCRIPTUM)) $criteria->add(CategoryI18nTableMap::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(CategoryI18nTableMap::DATABASE_NAME); + $criteria->add(CategoryI18nTableMap::ID, $this->id); + $criteria->add(CategoryI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\CategoryI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $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 ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addCategoryI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->id !== null)) { + $this->aCategory = ChildCategoryQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCategory = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CategoryI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php b/core/lib/Thelia/Model/Base/CategoryI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php rename to core/lib/Thelia/Model/Base/CategoryI18nQuery.php index 50d754e67..595a72aa9 --- a/core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return CategoryI18n|CategoryI18n[]|mixed the result, formatted by the current formatter + * @return ChildCategoryI18n|array|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 + if ((null !== ($obj = CategoryI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CategoryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CategoryI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return CategoryI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildCategoryI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `category_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CategoryI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCategoryI18n(); $obj->hydrate($row); - CategoryI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + CategoryI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return CategoryI18n|CategoryI18n[]|mixed the result, formatted by the current formatter + * @return ChildCategoryI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|CategoryI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CategoryI18nQuery The current query, for fluid interface + * @return ChildCategoryI18nQuery 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); + $this->addUsingAlias(CategoryI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CategoryI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CategoryI18nQuery The current query, for fluid interface + * @return ChildCategoryI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(CategoryI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CategoryI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByCategory() @@ -270,18 +266,18 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * 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 + * @return ChildCategoryI18nQuery 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); + $this->addUsingAlias(CategoryI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CategoryI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(CategoryI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * 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 + * @return ChildCategoryI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(CategoryI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * 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 + * @return ChildCategoryI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(CategoryI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * 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 + * @return ChildCategoryI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(CategoryI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * 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 + * @return ChildCategoryI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(CategoryI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * 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 + * @return ChildCategoryI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(CategoryI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Category object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Category|ObjectCollection $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. + * @return ChildCategoryI18nQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = null) { - if ($category instanceof Category) { + if ($category instanceof \Thelia\Model\Category) { return $this - ->addUsingAlias(CategoryI18nPeer::ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryI18nTableMap::ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(CategoryI18nPeer::ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(CategoryI18nTableMap::ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria * @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 + * @return ChildCategoryI18nQuery The current query, for fluid interface */ public function joinCategory($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria /** * Use the Category relation Category object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseCategoryI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param CategoryI18n $categoryI18n Object to remove from the list of results + * @param ChildCategoryI18n $categoryI18n Object to remove from the list of results * - * @return CategoryI18nQuery The current query, for fluid interface + * @return ChildCategoryI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(CategoryI18nTableMap::ID), $categoryI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CategoryI18nTableMap::LOCALE), $categoryI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the category_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CategoryI18nTableMap::clearInstancePool(); + CategoryI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCategoryI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCategoryI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CategoryI18nTableMap::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(); + + + CategoryI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CategoryI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CategoryI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseCategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php old mode 100755 new mode 100644 similarity index 59% rename from core/lib/Thelia/Model/om/BaseCategoryQuery.php rename to core/lib/Thelia/Model/Base/CategoryQuery.php index dd7550fae..caf05cbec --- a/core/lib/Thelia/Model/om/BaseCategoryQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryQuery.php @@ -1,154 +1,151 @@ setModelAlias($modelAlias); } @@ -169,21 +166,21 @@ abstract class BaseCategoryQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Category|Category[]|mixed the result, formatted by the current formatter + * @return ChildCategory|array|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 + if ((null !== ($obj = CategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CategoryTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -195,46 +192,31 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Category A model object, or null if the key is not found - * @throws PropelException + * @return ChildCategory A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Category(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCategory(); $obj->hydrate($row); - CategoryPeer::addInstanceToPool($obj, (string) $key); + CategoryTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -245,19 +227,19 @@ abstract class BaseCategoryQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Category|Category[]|mixed the result, formatted by the current formatter + * @return ChildCategory|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -266,22 +248,22 @@ abstract class BaseCategoryQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Category[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -289,12 +271,12 @@ abstract class BaseCategoryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CategoryQuery The current query, for fluid interface + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(CategoryPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(CategoryTableMap::ID, $key, Criteria::EQUAL); } /** @@ -302,12 +284,12 @@ abstract class BaseCategoryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CategoryQuery The current query, for fluid interface + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(CategoryPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(CategoryTableMap::ID, $keys, Criteria::IN); } /** @@ -317,8 +299,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -327,18 +308,18 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery 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); + $this->addUsingAlias(CategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CategoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -349,7 +330,7 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::ID, $id, $comparison); + return $this->addUsingAlias(CategoryTableMap::ID, $id, $comparison); } /** @@ -359,8 +340,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $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 + * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 * * * @param mixed $parent The value to use as filter. @@ -369,18 +349,18 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery 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); + $this->addUsingAlias(CategoryTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($parent['max'])) { - $this->addUsingAlias(CategoryPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -391,7 +371,7 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::PARENT, $parent, $comparison); + return $this->addUsingAlias(CategoryTableMap::PARENT, $parent, $comparison); } /** @@ -407,7 +387,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByLink($link = null, $comparison = null) { @@ -420,7 +400,7 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::LINK, $link, $comparison); + return $this->addUsingAlias(CategoryTableMap::LINK, $link, $comparison); } /** @@ -430,8 +410,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $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 + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 * * * @param mixed $visible The value to use as filter. @@ -440,18 +419,18 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery 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); + $this->addUsingAlias(CategoryTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($visible['max'])) { - $this->addUsingAlias(CategoryPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -462,7 +441,7 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::VISIBLE, $visible, $comparison); + return $this->addUsingAlias(CategoryTableMap::VISIBLE, $visible, $comparison); } /** @@ -472,8 +451,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -482,18 +460,18 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery 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); + $this->addUsingAlias(CategoryTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(CategoryPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -504,7 +482,7 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(CategoryTableMap::POSITION, $position, $comparison); } /** @@ -525,18 +503,18 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery 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); + $this->addUsingAlias(CategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -547,7 +525,7 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CategoryTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -568,18 +546,18 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery 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); + $this->addUsingAlias(CategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -590,7 +568,7 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CategoryTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -600,8 +578,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -610,18 +587,18 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery 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); + $this->addUsingAlias(CategoryTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(CategoryPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -632,7 +609,7 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::VERSION, $version, $comparison); + return $this->addUsingAlias(CategoryTableMap::VERSION, $version, $comparison); } /** @@ -653,18 +630,18 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery 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); + $this->addUsingAlias(CategoryTableMap::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); + $this->addUsingAlias(CategoryTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -675,7 +652,7 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(CategoryTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -691,7 +668,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -704,30 +681,29 @@ abstract class BaseCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(CategoryTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related ProductCategory object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ProductCategory|ObjectCollection $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. + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByProductCategory($productCategory, $comparison = null) { - if ($productCategory instanceof ProductCategory) { + if ($productCategory instanceof \Thelia\Model\ProductCategory) { return $this - ->addUsingAlias(CategoryPeer::ID, $productCategory->getCategoryId(), $comparison); - } elseif ($productCategory instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryTableMap::ID, $productCategory->getCategoryId(), $comparison); + } elseif ($productCategory instanceof ObjectCollection) { return $this ->useProductCategoryQuery() ->filterByPrimaryKeys($productCategory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection'); + throw new PropelException('filterByProductCategory() only accepts arguments of type \Thelia\Model\ProductCategory or Collection'); } } @@ -737,7 +713,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -766,7 +742,7 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Use the ProductCategory relation ProductCategory object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -782,26 +758,25 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related FeatureCategory object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureCategory|ObjectCollection $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. + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByFeatureCategory($featureCategory, $comparison = null) { - if ($featureCategory instanceof FeatureCategory) { + if ($featureCategory instanceof \Thelia\Model\FeatureCategory) { return $this - ->addUsingAlias(CategoryPeer::ID, $featureCategory->getCategoryId(), $comparison); - } elseif ($featureCategory instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryTableMap::ID, $featureCategory->getCategoryId(), $comparison); + } elseif ($featureCategory instanceof ObjectCollection) { return $this ->useFeatureCategoryQuery() ->filterByPrimaryKeys($featureCategory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection'); + throw new PropelException('filterByFeatureCategory() only accepts arguments of type \Thelia\Model\FeatureCategory or Collection'); } } @@ -811,7 +786,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -840,7 +815,7 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Use the FeatureCategory relation FeatureCategory object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -856,26 +831,25 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related AttributeCategory object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AttributeCategory|ObjectCollection $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. + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByAttributeCategory($attributeCategory, $comparison = null) { - if ($attributeCategory instanceof AttributeCategory) { + if ($attributeCategory instanceof \Thelia\Model\AttributeCategory) { return $this - ->addUsingAlias(CategoryPeer::ID, $attributeCategory->getCategoryId(), $comparison); - } elseif ($attributeCategory instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryTableMap::ID, $attributeCategory->getCategoryId(), $comparison); + } elseif ($attributeCategory instanceof ObjectCollection) { return $this ->useAttributeCategoryQuery() ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection'); + throw new PropelException('filterByAttributeCategory() only accepts arguments of type \Thelia\Model\AttributeCategory or Collection'); } } @@ -885,7 +859,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -914,7 +888,7 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Use the AttributeCategory relation AttributeCategory object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -930,26 +904,25 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related ContentAssoc object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ContentAssoc|ObjectCollection $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. + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByContentAssoc($contentAssoc, $comparison = null) { - if ($contentAssoc instanceof ContentAssoc) { + if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) { return $this - ->addUsingAlias(CategoryPeer::ID, $contentAssoc->getCategoryId(), $comparison); - } elseif ($contentAssoc instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryTableMap::ID, $contentAssoc->getCategoryId(), $comparison); + } elseif ($contentAssoc instanceof ObjectCollection) { return $this ->useContentAssocQuery() ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); + throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection'); } } @@ -959,7 +932,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -988,7 +961,7 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Use the ContentAssoc relation ContentAssoc object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1004,26 +977,25 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related Image object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Image|ObjectCollection $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. + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByImage($image, $comparison = null) { - if ($image instanceof Image) { + if ($image instanceof \Thelia\Model\Image) { return $this - ->addUsingAlias(CategoryPeer::ID, $image->getCategoryId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryTableMap::ID, $image->getCategoryId(), $comparison); + } elseif ($image instanceof ObjectCollection) { return $this ->useImageQuery() ->filterByPrimaryKeys($image->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); + throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); } } @@ -1033,7 +1005,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1062,7 +1034,7 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Use the Image relation Image object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1078,26 +1050,25 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related Document object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Document|ObjectCollection $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. + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByDocument($document, $comparison = null) { - if ($document instanceof Document) { + if ($document instanceof \Thelia\Model\Document) { return $this - ->addUsingAlias(CategoryPeer::ID, $document->getCategoryId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryTableMap::ID, $document->getCategoryId(), $comparison); + } elseif ($document instanceof ObjectCollection) { return $this ->useDocumentQuery() ->filterByPrimaryKeys($document->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); + throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); } } @@ -1107,7 +1078,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1136,7 +1107,7 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Use the Document relation Document object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1152,26 +1123,25 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related Rewriting object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Rewriting|ObjectCollection $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. + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByRewriting($rewriting, $comparison = null) { - if ($rewriting instanceof Rewriting) { + if ($rewriting instanceof \Thelia\Model\Rewriting) { return $this - ->addUsingAlias(CategoryPeer::ID, $rewriting->getCategoryId(), $comparison); - } elseif ($rewriting instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryTableMap::ID, $rewriting->getCategoryId(), $comparison); + } elseif ($rewriting instanceof ObjectCollection) { return $this ->useRewritingQuery() ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection'); + throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection'); } } @@ -1181,7 +1151,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1210,7 +1180,7 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Use the Rewriting relation Rewriting object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1226,26 +1196,25 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related CategoryI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\CategoryI18n|ObjectCollection $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. + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByCategoryI18n($categoryI18n, $comparison = null) { - if ($categoryI18n instanceof CategoryI18n) { + if ($categoryI18n instanceof \Thelia\Model\CategoryI18n) { return $this - ->addUsingAlias(CategoryPeer::ID, $categoryI18n->getId(), $comparison); - } elseif ($categoryI18n instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryTableMap::ID, $categoryI18n->getId(), $comparison); + } elseif ($categoryI18n instanceof ObjectCollection) { return $this ->useCategoryI18nQuery() ->filterByPrimaryKeys($categoryI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCategoryI18n() only accepts arguments of type CategoryI18n or PropelCollection'); + throw new PropelException('filterByCategoryI18n() only accepts arguments of type \Thelia\Model\CategoryI18n or Collection'); } } @@ -1255,7 +1224,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function joinCategoryI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -1284,7 +1253,7 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Use the CategoryI18n relation CategoryI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1300,26 +1269,25 @@ abstract class BaseCategoryQuery extends ModelCriteria } /** - * Filter the query by a related CategoryVersion object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\CategoryVersion|ObjectCollection $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. + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByCategoryVersion($categoryVersion, $comparison = null) { - if ($categoryVersion instanceof CategoryVersion) { + if ($categoryVersion instanceof \Thelia\Model\CategoryVersion) { return $this - ->addUsingAlias(CategoryPeer::ID, $categoryVersion->getId(), $comparison); - } elseif ($categoryVersion instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryTableMap::ID, $categoryVersion->getId(), $comparison); + } elseif ($categoryVersion instanceof ObjectCollection) { return $this ->useCategoryVersionQuery() ->filterByPrimaryKeys($categoryVersion->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCategoryVersion() only accepts arguments of type CategoryVersion or PropelCollection'); + throw new PropelException('filterByCategoryVersion() only accepts arguments of type \Thelia\Model\CategoryVersion or Collection'); } } @@ -1329,7 +1297,7 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function joinCategoryVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1358,7 +1326,7 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Use the CategoryVersion relation CategoryVersion object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1377,10 +1345,10 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = Criteria::EQUAL) { @@ -1394,10 +1362,10 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByFeature($feature, $comparison = Criteria::EQUAL) { @@ -1411,10 +1379,10 @@ abstract class BaseCategoryQuery extends ModelCriteria * 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 + * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ public function filterByAttribute($attribute, $comparison = Criteria::EQUAL) { @@ -1427,19 +1395,94 @@ abstract class BaseCategoryQuery extends ModelCriteria /** * Exclude object from result * - * @param Category $category Object to remove from the list of results + * @param ChildCategory $category Object to remove from the list of results * - * @return CategoryQuery The current query, for fluid interface + * @return ChildCategoryQuery The current query, for fluid interface */ public function prune($category = null) { if ($category) { - $this->addUsingAlias(CategoryPeer::ID, $category->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(CategoryTableMap::ID, $category->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the category table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CategoryTableMap::clearInstancePool(); + CategoryTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCategory or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCategory object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CategoryTableMap::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(); + + + CategoryTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CategoryTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -1447,31 +1490,11 @@ abstract class BaseCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return CategoryQuery The current query, for fluid interface + * @return ChildCategoryQuery 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); + return $this->addUsingAlias(CategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -1479,32 +1502,53 @@ abstract class BaseCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return CategoryQuery The current query, for fluid interface + * @return ChildCategoryQuery 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); + return $this->addUsingAlias(CategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CategoryTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCategoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CategoryTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return CategoryQuery The current query, for fluid interface + * @return ChildCategoryQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(CategoryPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(CategoryTableMap::CREATED_AT); } /** * Order by create date asc * - * @return CategoryQuery The current query, for fluid interface + * @return ChildCategoryQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(CategoryPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(CategoryTableMap::CREATED_AT); } + // i18n behavior /** @@ -1514,9 +1558,9 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CategoryI18n'; @@ -1532,9 +1576,9 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1553,13 +1597,41 @@ abstract class BaseCategoryQuery extends ModelCriteria * @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 + * @return ChildCategoryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CategoryI18n', 'Thelia\Model\CategoryI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'CategoryI18n', '\Thelia\Model\CategoryI18nQuery'); } -} + // versionable behavior + + /** + * Checks whether versioning is enabled + * + * @return boolean + */ + static public function isVersioningEnabled() + { + return self::$isVersioningEnabled; + } + + /** + * Enables versioning + */ + static public function enableVersioning() + { + self::$isVersioningEnabled = true; + } + + /** + * Disables versioning + */ + static public function disableVersioning() + { + self::$isVersioningEnabled = false; + } + +} // CategoryQuery diff --git a/core/lib/Thelia/Model/Base/CategoryVersion.php b/core/lib/Thelia/Model/Base/CategoryVersion.php new file mode 100644 index 000000000..807e26b79 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CategoryVersion.php @@ -0,0 +1,1709 @@ +version = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\CategoryVersion object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CategoryVersion instance. If + * obj is an instance of CategoryVersion, delegates to + * equals(CategoryVersion). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CategoryVersion The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CategoryVersion The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + } + } + + /** + * 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 \Thelia\Model\CategoryVersion The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CategoryVersionTableMap::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 \Thelia\Model\CategoryVersion The current object (for fluent API support) + */ + public function setParent($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->parent !== $v) { + $this->parent = $v; + $this->modifiedColumns[] = CategoryVersionTableMap::PARENT; + } + + + return $this; + } // setParent() + + /** + * Set the value of [link] column. + * + * @param string $v new value + * @return \Thelia\Model\CategoryVersion The current object (for fluent API support) + */ + public function setLink($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->link !== $v) { + $this->link = $v; + $this->modifiedColumns[] = CategoryVersionTableMap::LINK; + } + + + return $this; + } // setLink() + + /** + * Set the value of [visible] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryVersion The current object (for fluent API support) + */ + public function setVisible($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->visible !== $v) { + $this->visible = $v; + $this->modifiedColumns[] = CategoryVersionTableMap::VISIBLE; + } + + + return $this; + } // setVisible() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryVersion The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = CategoryVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CategoryVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CategoryVersionTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Set the value of [version] column. + * + * @param int $v new value + * @return \Thelia\Model\CategoryVersion The current object (for fluent API support) + */ + public function setVersion($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->version !== $v) { + $this->version = $v; + $this->modifiedColumns[] = CategoryVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = CategoryVersionTableMap::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 \Thelia\Model\CategoryVersion The current object (for fluent API support) + */ + public function setVersionCreatedBy($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->version_created_by !== $v) { + $this->version_created_by = $v; + $this->modifiedColumns[] = CategoryVersionTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CategoryVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CategoryVersionTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $this->parent = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CategoryVersionTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)]; + $this->link = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CategoryVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CategoryVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CategoryVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CategoryVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CategoryVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CategoryVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CategoryVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 10; // 10 = CategoryVersionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CategoryVersion object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(CategoryVersionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCategoryVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCategory = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CategoryVersion::setDeleted() + * @see CategoryVersion::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCategoryVersionQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME); + } + + $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); + CategoryVersionTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CategoryVersionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CategoryVersionTableMap::PARENT)) { + $modifiedColumns[':p' . $index++] = 'PARENT'; + } + if ($this->isColumnModified(CategoryVersionTableMap::LINK)) { + $modifiedColumns[':p' . $index++] = 'LINK'; + } + if ($this->isColumnModified(CategoryVersionTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; + } + if ($this->isColumnModified(CategoryVersionTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(CategoryVersionTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(CategoryVersionTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + if ($this->isColumnModified(CategoryVersionTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; + } + if ($this->isColumnModified(CategoryVersionTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; + } + if ($this->isColumnModified(CategoryVersionTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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 ? $this->version_created_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryVersionTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CategoryVersion'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CategoryVersion'][serialize($this->getPrimaryKey())] = true; + $keys = CategoryVersionTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CategoryVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = CategoryVersionTableMap::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(CategoryVersionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CategoryVersionTableMap::ID)) $criteria->add(CategoryVersionTableMap::ID, $this->id); + if ($this->isColumnModified(CategoryVersionTableMap::PARENT)) $criteria->add(CategoryVersionTableMap::PARENT, $this->parent); + if ($this->isColumnModified(CategoryVersionTableMap::LINK)) $criteria->add(CategoryVersionTableMap::LINK, $this->link); + if ($this->isColumnModified(CategoryVersionTableMap::VISIBLE)) $criteria->add(CategoryVersionTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(CategoryVersionTableMap::POSITION)) $criteria->add(CategoryVersionTableMap::POSITION, $this->position); + if ($this->isColumnModified(CategoryVersionTableMap::CREATED_AT)) $criteria->add(CategoryVersionTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CategoryVersionTableMap::UPDATED_AT)) $criteria->add(CategoryVersionTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(CategoryVersionTableMap::VERSION)) $criteria->add(CategoryVersionTableMap::VERSION, $this->version); + if ($this->isColumnModified(CategoryVersionTableMap::VERSION_CREATED_AT)) $criteria->add(CategoryVersionTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(CategoryVersionTableMap::VERSION_CREATED_BY)) $criteria->add(CategoryVersionTableMap::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(CategoryVersionTableMap::DATABASE_NAME); + $criteria->add(CategoryVersionTableMap::ID, $this->id); + $criteria->add(CategoryVersionTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\CategoryVersion The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $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 ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addCategoryVersion($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->id !== null)) { + $this->aCategory = ChildCategoryQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCategory = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CategoryVersionTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php b/core/lib/Thelia/Model/Base/CategoryVersionQuery.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php rename to core/lib/Thelia/Model/Base/CategoryVersionQuery.php index 957c2ee50..3eac5e8cd --- a/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryVersionQuery.php @@ -1,112 +1,111 @@ setModelAlias($modelAlias); } @@ -126,23 +125,22 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * $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 + * @param array[$id, $version] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return CategoryVersion|CategoryVersion[]|mixed the result, formatted by the current formatter + * @return ChildCategoryVersion|array|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 + if ((null !== ($obj = CategoryVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CategoryVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CategoryVersionTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -159,14 +157,13 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return CategoryVersion A model object, or null if the key is not found - * @throws PropelException + * @return ChildCategoryVersion A model object, or null if the key is not found */ 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'; + $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); @@ -174,13 +171,13 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CategoryVersion(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCategoryVersion(); $obj->hydrate($row); - CategoryVersionPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + CategoryVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -191,19 +188,19 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return CategoryVersion|CategoryVersion[]|mixed the result, formatted by the current formatter + * @return ChildCategoryVersion|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -212,22 +209,22 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|CategoryVersion[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -235,12 +232,12 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CategoryVersionQuery The current query, for fluid interface + * @return ChildCategoryVersionQuery 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); + $this->addUsingAlias(CategoryVersionTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CategoryVersionTableMap::VERSION, $key[1], Criteria::EQUAL); return $this; } @@ -250,7 +247,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CategoryVersionQuery The current query, for fluid interface + * @return ChildCategoryVersionQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -258,8 +255,8 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria 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 = $this->getNewCriterion(CategoryVersionTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CategoryVersionTableMap::VERSION, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -274,8 +271,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByCategory() @@ -286,18 +282,18 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery 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); + $this->addUsingAlias(CategoryVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CategoryVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -308,7 +304,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::ID, $id, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::ID, $id, $comparison); } /** @@ -318,8 +314,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $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 + * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 * * * @param mixed $parent The value to use as filter. @@ -328,18 +323,18 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery 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); + $this->addUsingAlias(CategoryVersionTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($parent['max'])) { - $this->addUsingAlias(CategoryVersionPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryVersionTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -350,7 +345,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::PARENT, $parent, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::PARENT, $parent, $comparison); } /** @@ -366,7 +361,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery The current query, for fluid interface */ public function filterByLink($link = null, $comparison = null) { @@ -379,7 +374,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::LINK, $link, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::LINK, $link, $comparison); } /** @@ -389,8 +384,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $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 + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 * * * @param mixed $visible The value to use as filter. @@ -399,18 +393,18 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery 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); + $this->addUsingAlias(CategoryVersionTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($visible['max'])) { - $this->addUsingAlias(CategoryVersionPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryVersionTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -421,7 +415,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::VISIBLE, $visible, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::VISIBLE, $visible, $comparison); } /** @@ -431,8 +425,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -441,18 +434,18 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery 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); + $this->addUsingAlias(CategoryVersionTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(CategoryVersionPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryVersionTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -463,7 +456,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::POSITION, $position, $comparison); } /** @@ -484,18 +477,18 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery 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); + $this->addUsingAlias(CategoryVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CategoryVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -506,7 +499,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -527,18 +520,18 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery 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); + $this->addUsingAlias(CategoryVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CategoryVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -549,7 +542,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -559,8 +552,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -569,18 +561,18 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery 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); + $this->addUsingAlias(CategoryVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(CategoryVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CategoryVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -591,7 +583,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::VERSION, $version, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::VERSION, $version, $comparison); } /** @@ -612,18 +604,18 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery 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); + $this->addUsingAlias(CategoryVersionTableMap::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); + $this->addUsingAlias(CategoryVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -634,7 +626,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -650,7 +642,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * 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 + * @return ChildCategoryVersionQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -663,32 +655,31 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(CategoryVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(CategoryVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related Category object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Category|ObjectCollection $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. + * @return ChildCategoryVersionQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = null) { - if ($category instanceof Category) { + if ($category instanceof \Thelia\Model\Category) { return $this - ->addUsingAlias(CategoryVersionPeer::ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { + ->addUsingAlias(CategoryVersionTableMap::ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(CategoryVersionPeer::ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(CategoryVersionTableMap::ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); } } @@ -698,7 +689,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria * @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 + * @return ChildCategoryVersionQuery The current query, for fluid interface */ public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -727,7 +718,7 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria /** * Use the Category relation Category object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -745,19 +736,94 @@ abstract class BaseCategoryVersionQuery extends ModelCriteria /** * Exclude object from result * - * @param CategoryVersion $categoryVersion Object to remove from the list of results + * @param ChildCategoryVersion $categoryVersion Object to remove from the list of results * - * @return CategoryVersionQuery The current query, for fluid interface + * @return ChildCategoryVersionQuery 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->addCond('pruneCond0', $this->getAliasedColName(CategoryVersionTableMap::ID), $categoryVersion->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CategoryVersionTableMap::VERSION), $categoryVersion->getVersion(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the category_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CategoryVersionTableMap::clearInstancePool(); + CategoryVersionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCategoryVersion or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCategoryVersion object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CategoryVersionTableMap::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(); + + + CategoryVersionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CategoryVersionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CategoryVersionQuery diff --git a/core/lib/Thelia/Model/om/BaseCombination.php b/core/lib/Thelia/Model/Base/Combination.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseCombination.php rename to core/lib/Thelia/Model/Base/Combination.php index a05fa4e5c..e7cd93da7 --- a/core/lib/Thelia/Model/om/BaseCombination.php +++ b/core/lib/Thelia/Model/Base/Combination.php @@ -1,55 +1,63 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Combination instance. If + * obj is an instance of Combination, delegates to + * equals(Combination). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Combination The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Combination The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [ref] column value. * - * @return string + * @return string */ public function getRef() { + return $this->ref; } @@ -143,97 +395,57 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Combination The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = CombinationPeer::ID; + $this->modifiedColumns[] = CombinationTableMap::ID; } @@ -243,18 +455,18 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * Set the value of [ref] column. * - * @param string $v new value - * @return Combination The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Combination The current object (for fluent API support) */ public function setRef($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->ref !== $v) { $this->ref = $v; - $this->modifiedColumns[] = CombinationPeer::REF; + $this->modifiedColumns[] = CombinationTableMap::REF; } @@ -264,19 +476,17 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Combination The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CombinationTableMap::CREATED_AT; } } // if either are not null @@ -287,19 +497,17 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Combination The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CombinationTableMap::UPDATED_AT; } } // if either are not null @@ -317,7 +525,7 @@ abstract class BaseCombination extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -329,20 +537,38 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CombinationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CombinationTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CombinationTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CombinationTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -350,11 +576,11 @@ abstract class BaseCombination extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = CombinationPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 4; // 4 = CombinationTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Combination object", $e); + throw new PropelException("Error populating \Thelia\Model\Combination object", 0, $e); } } @@ -373,7 +599,6 @@ abstract class BaseCombination extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -381,12 +606,12 @@ abstract class BaseCombination extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -397,19 +622,19 @@ abstract class BaseCombination extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CombinationTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildCombinationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -423,26 +648,25 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Combination::setDeleted() + * @see Combination::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = CombinationQuery::create() + $deleteQuery = ChildCombinationQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -467,20 +691,19 @@ abstract class BaseCombination extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -490,16 +713,16 @@ abstract class BaseCombination extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(CombinationPeer::CREATED_AT)) { + if (!$this->isColumnModified(CombinationTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(CombinationPeer::UPDATED_AT)) { + if (!$this->isColumnModified(CombinationTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CombinationPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(CombinationTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -511,7 +734,7 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - CombinationPeer::addInstanceToPool($this); + CombinationTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -530,12 +753,12 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -554,15 +777,15 @@ abstract class BaseCombination extends BaseObject implements Persistent if ($this->attributeCombinationsScheduledForDeletion !== null) { if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) { - AttributeCombinationQuery::create() + \Thelia\Model\AttributeCombinationQuery::create() ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->attributeCombinationsScheduledForDeletion = null; } } - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { + if ($this->collAttributeCombinations !== null) { + foreach ($this->collAttributeCombinations as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -579,8 +802,8 @@ abstract class BaseCombination extends BaseObject implements Persistent } } - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { + if ($this->collStocks !== null) { + foreach ($this->collStocks as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -597,37 +820,37 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = CombinationPeer::ID; + $this->modifiedColumns[] = CombinationTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CombinationPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CombinationTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CombinationPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(CombinationTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(CombinationPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; + if ($this->isColumnModified(CombinationTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; } - if ($this->isColumnModified(CombinationPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(CombinationTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(CombinationPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(CombinationTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `combination` (%s) VALUES (%s)', + 'INSERT INTO combination (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -636,30 +859,30 @@ abstract class BaseCombination extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`ref`': + case 'REF': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -669,120 +892,32 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = CombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -792,7 +927,7 @@ abstract class BaseCombination extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -822,28 +957,34 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = CombinationTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getRef(), $keys[2] => $this->getCreatedAt(), $keys[3] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collAttributeCombinations) { $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -859,27 +1000,27 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = CombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CombinationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -909,17 +1050,17 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = CombinationPeer::getFieldNames($keyType); + $keys = CombinationTableMap::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]]); @@ -934,12 +1075,12 @@ abstract class BaseCombination extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(CombinationPeer::DATABASE_NAME); + $criteria = new Criteria(CombinationTableMap::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); + if ($this->isColumnModified(CombinationTableMap::ID)) $criteria->add(CombinationTableMap::ID, $this->id); + if ($this->isColumnModified(CombinationTableMap::REF)) $criteria->add(CombinationTableMap::REF, $this->ref); + if ($this->isColumnModified(CombinationTableMap::CREATED_AT)) $criteria->add(CombinationTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CombinationTableMap::UPDATED_AT)) $criteria->add(CombinationTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -954,15 +1095,15 @@ abstract class BaseCombination extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(CombinationPeer::DATABASE_NAME); - $criteria->add(CombinationPeer::ID, $this->id); + $criteria = new Criteria(CombinationTableMap::DATABASE_NAME); + $criteria->add(CombinationTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -972,7 +1113,7 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -996,9 +1137,9 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1007,12 +1148,10 @@ abstract class BaseCombination extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1026,8 +1165,6 @@ abstract class BaseCombination extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1044,8 +1181,8 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Combination Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1058,40 +1195,22 @@ abstract class BaseCombination extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('AttributeCombination' == $relationName) { - $this->initAttributeCombinations(); + return $this->initAttributeCombinations(); } if ('Stock' == $relationName) { - $this->initStocks(); + return $this->initStocks(); } } @@ -1101,21 +1220,16 @@ abstract class BaseCombination extends BaseObject implements Persistent * This 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) + * @return void * @see addAttributeCombinations() */ public function clearAttributeCombinations() { - $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized - $this->collAttributeCombinationsPartial = null; - - return $this; + $this->collAttributeCombinations = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collAttributeCombinations collection loaded partially - * - * @return void + * Reset is the collAttributeCombinations collection loaded partially. */ public function resetPartialAttributeCombinations($v = true) { @@ -1129,7 +1243,7 @@ abstract class BaseCombination extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1139,25 +1253,25 @@ abstract class BaseCombination extends BaseObject implements Persistent if (null !== $this->collAttributeCombinations && !$overrideExisting) { return; } - $this->collAttributeCombinations = new PropelObjectCollection(); - $this->collAttributeCombinations->setModel('AttributeCombination'); + $this->collAttributeCombinations = new ObjectCollection(); + $this->collAttributeCombinations->setModel('\Thelia\Model\AttributeCombination'); } /** - * Gets an array of AttributeCombination objects which contain a foreign key that references this object. + * Gets an array of ChildAttributeCombination objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCombination is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects * @throws PropelException */ - public function getAttributeCombinations($criteria = null, PropelPDO $con = null) + public function getAttributeCombinations($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { @@ -1165,29 +1279,31 @@ abstract class BaseCombination extends BaseObject implements Persistent // return empty collection $this->initAttributeCombinations(); } else { - $collAttributeCombinations = AttributeCombinationQuery::create(null, $criteria) + $collAttributeCombinations = ChildAttributeCombinationQuery::create(null, $criteria) ->filterByCombination($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) { - $this->initAttributeCombinations(false); + $this->initAttributeCombinations(false); - foreach($collAttributeCombinations as $obj) { - if (false == $this->collAttributeCombinations->contains($obj)) { - $this->collAttributeCombinations->append($obj); + foreach ($collAttributeCombinations as $obj) { + if (false == $this->collAttributeCombinations->contains($obj)) { + $this->collAttributeCombinations->append($obj); + } } - } - $this->collAttributeCombinationsPartial = true; + $this->collAttributeCombinationsPartial = true; } $collAttributeCombinations->getInternalIterator()->rewind(); + return $collAttributeCombinations; } - if($partial && $this->collAttributeCombinations) { - foreach($this->collAttributeCombinations as $obj) { - if($obj->isNew()) { + if ($partial && $this->collAttributeCombinations) { + foreach ($this->collAttributeCombinations as $obj) { + if ($obj->isNew()) { $collAttributeCombinations[] = $obj; } } @@ -1207,15 +1323,19 @@ abstract class BaseCombination extends BaseObject implements Persistent * It will 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) + * @param Collection $attributeCombinations A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCombination The current object (for fluent API support) */ - public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null) + public function setAttributeCombinations(Collection $attributeCombinations, ConnectionInterface $con = null) { $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - $this->attributeCombinationsScheduledForDeletion = unserialize(serialize($attributeCombinationsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->attributeCombinationsScheduledForDeletion = clone $attributeCombinationsToDelete; foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { $attributeCombinationRemoved->setCombination(null); @@ -1235,13 +1355,13 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * Returns the number of related AttributeCombination objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AttributeCombination objects. * @throws PropelException */ - public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { @@ -1249,10 +1369,11 @@ abstract class BaseCombination extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getAttributeCombinations()); } - $query = AttributeCombinationQuery::create(null, $criteria); + + $query = ChildAttributeCombinationQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1266,18 +1387,19 @@ abstract class BaseCombination extends BaseObject implements Persistent } /** - * Method called to associate a AttributeCombination object to this object - * through the AttributeCombination foreign key attribute. + * Method called to associate a ChildAttributeCombination object to this object + * through the ChildAttributeCombination foreign key attribute. * - * @param AttributeCombination $l AttributeCombination - * @return Combination The current object (for fluent API support) + * @param ChildAttributeCombination $l ChildAttributeCombination + * @return \Thelia\Model\Combination The current object (for fluent API support) */ - public function addAttributeCombination(AttributeCombination $l) + public function addAttributeCombination(ChildAttributeCombination $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); } @@ -1286,7 +1408,7 @@ abstract class BaseCombination extends BaseObject implements Persistent } /** - * @param AttributeCombination $attributeCombination The attributeCombination object to add. + * @param AttributeCombination $attributeCombination The attributeCombination object to add. */ protected function doAddAttributeCombination($attributeCombination) { @@ -1295,8 +1417,8 @@ abstract class BaseCombination extends BaseObject implements Persistent } /** - * @param AttributeCombination $attributeCombination The attributeCombination object to remove. - * @return Combination The current object (for fluent API support) + * @param AttributeCombination $attributeCombination The attributeCombination object to remove. + * @return ChildCombination The current object (for fluent API support) */ public function removeAttributeCombination($attributeCombination) { @@ -1325,15 +1447,15 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects */ - public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Attribute', $join_behavior); + $query = ChildAttributeCombinationQuery::create(null, $criteria); + $query->joinWith('Attribute', $joinBehavior); return $this->getAttributeCombinations($query, $con); } @@ -1350,15 +1472,15 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAttributeCombination[] List of ChildAttributeCombination objects */ - public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('AttributeAv', $join_behavior); + $query = ChildAttributeCombinationQuery::create(null, $criteria); + $query->joinWith('AttributeAv', $joinBehavior); return $this->getAttributeCombinations($query, $con); } @@ -1369,21 +1491,16 @@ abstract class BaseCombination extends BaseObject implements Persistent * This 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) + * @return void * @see addStocks() */ public function clearStocks() { - $this->collStocks = null; // important to set this to null since that means it is uninitialized - $this->collStocksPartial = null; - - return $this; + $this->collStocks = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collStocks collection loaded partially - * - * @return void + * Reset is the collStocks collection loaded partially. */ public function resetPartialStocks($v = true) { @@ -1397,7 +1514,7 @@ abstract class BaseCombination extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1407,25 +1524,25 @@ abstract class BaseCombination extends BaseObject implements Persistent if (null !== $this->collStocks && !$overrideExisting) { return; } - $this->collStocks = new PropelObjectCollection(); - $this->collStocks->setModel('Stock'); + $this->collStocks = new ObjectCollection(); + $this->collStocks->setModel('\Thelia\Model\Stock'); } /** - * Gets an array of Stock objects which contain a foreign key that references this object. + * Gets an array of ChildStock objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCombination is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildStock[] List of ChildStock objects * @throws PropelException */ - public function getStocks($criteria = null, PropelPDO $con = null) + public function getStocks($criteria = null, ConnectionInterface $con = null) { $partial = $this->collStocksPartial && !$this->isNew(); if (null === $this->collStocks || null !== $criteria || $partial) { @@ -1433,29 +1550,31 @@ abstract class BaseCombination extends BaseObject implements Persistent // return empty collection $this->initStocks(); } else { - $collStocks = StockQuery::create(null, $criteria) + $collStocks = ChildStockQuery::create(null, $criteria) ->filterByCombination($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collStocksPartial && count($collStocks)) { - $this->initStocks(false); + $this->initStocks(false); - foreach($collStocks as $obj) { - if (false == $this->collStocks->contains($obj)) { - $this->collStocks->append($obj); + foreach ($collStocks as $obj) { + if (false == $this->collStocks->contains($obj)) { + $this->collStocks->append($obj); + } } - } - $this->collStocksPartial = true; + $this->collStocksPartial = true; } $collStocks->getInternalIterator()->rewind(); + return $collStocks; } - if($partial && $this->collStocks) { - foreach($this->collStocks as $obj) { - if($obj->isNew()) { + if ($partial && $this->collStocks) { + foreach ($this->collStocks as $obj) { + if ($obj->isNew()) { $collStocks[] = $obj; } } @@ -1475,15 +1594,16 @@ abstract class BaseCombination extends BaseObject implements Persistent * It will 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) + * @param Collection $stocks A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCombination The current object (for fluent API support) */ - public function setStocks(PropelCollection $stocks, PropelPDO $con = null) + public function setStocks(Collection $stocks, ConnectionInterface $con = null) { $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks); - $this->stocksScheduledForDeletion = unserialize(serialize($stocksToDelete)); + + $this->stocksScheduledForDeletion = $stocksToDelete; foreach ($stocksToDelete as $stockRemoved) { $stockRemoved->setCombination(null); @@ -1503,13 +1623,13 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * Returns the number of related Stock objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Stock objects. * @throws PropelException */ - public function countStocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countStocks(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collStocksPartial && !$this->isNew(); if (null === $this->collStocks || null !== $criteria || $partial) { @@ -1517,10 +1637,11 @@ abstract class BaseCombination extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getStocks()); } - $query = StockQuery::create(null, $criteria); + + $query = ChildStockQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1534,18 +1655,19 @@ abstract class BaseCombination extends BaseObject implements Persistent } /** - * Method called to associate a Stock object to this object - * through the Stock foreign key attribute. + * Method called to associate a ChildStock object to this object + * through the ChildStock foreign key attribute. * - * @param Stock $l Stock - * @return Combination The current object (for fluent API support) + * @param ChildStock $l ChildStock + * @return \Thelia\Model\Combination The current object (for fluent API support) */ - public function addStock(Stock $l) + public function addStock(ChildStock $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); } @@ -1554,7 +1676,7 @@ abstract class BaseCombination extends BaseObject implements Persistent } /** - * @param Stock $stock The stock object to add. + * @param Stock $stock The stock object to add. */ protected function doAddStock($stock) { @@ -1563,8 +1685,8 @@ abstract class BaseCombination extends BaseObject implements Persistent } /** - * @param Stock $stock The stock object to remove. - * @return Combination The current object (for fluent API support) + * @param Stock $stock The stock object to remove. + * @return ChildCombination The current object (for fluent API support) */ public function removeStock($stock) { @@ -1593,15 +1715,15 @@ abstract class BaseCombination extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildStock[] List of ChildStock objects */ - public function getStocksJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getStocksJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = StockQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildStockQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getStocks($query, $con); } @@ -1616,8 +1738,6 @@ abstract class BaseCombination extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1629,14 +1749,13 @@ abstract class BaseCombination extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collAttributeCombinations) { foreach ($this->collAttributeCombinations as $o) { $o->clearAllReferences($deep); @@ -1647,38 +1766,26 @@ abstract class BaseCombination extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) - if ($this->collAttributeCombinations instanceof PropelCollection) { + if ($this->collAttributeCombinations instanceof Collection) { $this->collAttributeCombinations->clearIterator(); } $this->collAttributeCombinations = null; - if ($this->collStocks instanceof PropelCollection) { + if ($this->collStocks instanceof Collection) { $this->collStocks->clearIterator(); } $this->collStocks = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(CombinationTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1686,13 +1793,131 @@ abstract class BaseCombination extends BaseObject implements Persistent /** * 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) + * @return ChildCombination The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = CombinationPeer::UPDATED_AT; + $this->modifiedColumns[] = CombinationTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseCombinationQuery.php b/core/lib/Thelia/Model/Base/CombinationQuery.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseCombinationQuery.php rename to core/lib/Thelia/Model/Base/CombinationQuery.php index 325af53bf..7424f03f6 --- a/core/lib/Thelia/Model/om/BaseCombinationQuery.php +++ b/core/lib/Thelia/Model/Base/CombinationQuery.php @@ -1,92 +1,91 @@ setModelAlias($modelAlias); } @@ -107,21 +106,21 @@ abstract class BaseCombinationQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Combination|Combination[]|mixed the result, formatted by the current formatter + * @return ChildCombination|array|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 + if ((null !== ($obj = CombinationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CombinationTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -133,46 +132,31 @@ abstract class BaseCombinationQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Combination A model object, or null if the key is not found - * @throws PropelException + * @return ChildCombination A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `ref`, `created_at`, `updated_at` FROM `combination` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Combination(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCombination(); $obj->hydrate($row); - CombinationPeer::addInstanceToPool($obj, (string) $key); + CombinationTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -183,19 +167,19 @@ abstract class BaseCombinationQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Combination|Combination[]|mixed the result, formatted by the current formatter + * @return ChildCombination|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -204,22 +188,22 @@ abstract class BaseCombinationQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Combination[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -227,12 +211,12 @@ abstract class BaseCombinationQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CombinationQuery The current query, for fluid interface + * @return ChildCombinationQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(CombinationPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(CombinationTableMap::ID, $key, Criteria::EQUAL); } /** @@ -240,12 +224,12 @@ abstract class BaseCombinationQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CombinationQuery The current query, for fluid interface + * @return ChildCombinationQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(CombinationPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(CombinationTableMap::ID, $keys, Criteria::IN); } /** @@ -255,8 +239,7 @@ abstract class BaseCombinationQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -265,18 +248,18 @@ abstract class BaseCombinationQuery extends ModelCriteria * 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 + * @return ChildCombinationQuery 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); + $this->addUsingAlias(CombinationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CombinationPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CombinationTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -287,7 +270,7 @@ abstract class BaseCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(CombinationPeer::ID, $id, $comparison); + return $this->addUsingAlias(CombinationTableMap::ID, $id, $comparison); } /** @@ -303,7 +286,7 @@ abstract class BaseCombinationQuery extends ModelCriteria * 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 + * @return ChildCombinationQuery The current query, for fluid interface */ public function filterByRef($ref = null, $comparison = null) { @@ -316,7 +299,7 @@ abstract class BaseCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(CombinationPeer::REF, $ref, $comparison); + return $this->addUsingAlias(CombinationTableMap::REF, $ref, $comparison); } /** @@ -337,18 +320,18 @@ abstract class BaseCombinationQuery extends ModelCriteria * 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 + * @return ChildCombinationQuery 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); + $this->addUsingAlias(CombinationTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CombinationPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CombinationTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -359,7 +342,7 @@ abstract class BaseCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(CombinationPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CombinationTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -380,18 +363,18 @@ abstract class BaseCombinationQuery extends ModelCriteria * 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 + * @return ChildCombinationQuery 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); + $this->addUsingAlias(CombinationTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CombinationPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CombinationTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -402,30 +385,29 @@ abstract class BaseCombinationQuery extends ModelCriteria } } - return $this->addUsingAlias(CombinationPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CombinationTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related AttributeCombination object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AttributeCombination|ObjectCollection $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. + * @return ChildCombinationQuery The current query, for fluid interface */ public function filterByAttributeCombination($attributeCombination, $comparison = null) { - if ($attributeCombination instanceof AttributeCombination) { + if ($attributeCombination instanceof \Thelia\Model\AttributeCombination) { return $this - ->addUsingAlias(CombinationPeer::ID, $attributeCombination->getCombinationId(), $comparison); - } elseif ($attributeCombination instanceof PropelObjectCollection) { + ->addUsingAlias(CombinationTableMap::ID, $attributeCombination->getCombinationId(), $comparison); + } elseif ($attributeCombination instanceof ObjectCollection) { return $this ->useAttributeCombinationQuery() ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection'); + throw new PropelException('filterByAttributeCombination() only accepts arguments of type \Thelia\Model\AttributeCombination or Collection'); } } @@ -435,7 +417,7 @@ abstract class BaseCombinationQuery extends ModelCriteria * @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 + * @return ChildCombinationQuery The current query, for fluid interface */ public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -464,7 +446,7 @@ abstract class BaseCombinationQuery extends ModelCriteria /** * Use the AttributeCombination relation AttributeCombination object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -480,26 +462,25 @@ abstract class BaseCombinationQuery extends ModelCriteria } /** - * Filter the query by a related Stock object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Stock|ObjectCollection $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. + * @return ChildCombinationQuery The current query, for fluid interface */ public function filterByStock($stock, $comparison = null) { - if ($stock instanceof Stock) { + if ($stock instanceof \Thelia\Model\Stock) { return $this - ->addUsingAlias(CombinationPeer::ID, $stock->getCombinationId(), $comparison); - } elseif ($stock instanceof PropelObjectCollection) { + ->addUsingAlias(CombinationTableMap::ID, $stock->getCombinationId(), $comparison); + } elseif ($stock instanceof ObjectCollection) { return $this ->useStockQuery() ->filterByPrimaryKeys($stock->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection'); + throw new PropelException('filterByStock() only accepts arguments of type \Thelia\Model\Stock or Collection'); } } @@ -509,7 +490,7 @@ abstract class BaseCombinationQuery extends ModelCriteria * @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 + * @return ChildCombinationQuery The current query, for fluid interface */ public function joinStock($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -538,7 +519,7 @@ abstract class BaseCombinationQuery extends ModelCriteria /** * Use the Stock relation Stock object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -556,19 +537,94 @@ abstract class BaseCombinationQuery extends ModelCriteria /** * Exclude object from result * - * @param Combination $combination Object to remove from the list of results + * @param ChildCombination $combination Object to remove from the list of results * - * @return CombinationQuery The current query, for fluid interface + * @return ChildCombinationQuery The current query, for fluid interface */ public function prune($combination = null) { if ($combination) { - $this->addUsingAlias(CombinationPeer::ID, $combination->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(CombinationTableMap::ID, $combination->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the combination table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CombinationTableMap::clearInstancePool(); + CombinationTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCombination or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCombination object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CombinationTableMap::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(); + + + CombinationTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CombinationTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -576,31 +632,11 @@ abstract class BaseCombinationQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return CombinationQuery The current query, for fluid interface + * @return ChildCombinationQuery 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); + return $this->addUsingAlias(CombinationTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -608,30 +644,51 @@ abstract class BaseCombinationQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return CombinationQuery The current query, for fluid interface + * @return ChildCombinationQuery 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); + return $this->addUsingAlias(CombinationTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCombinationQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CombinationTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCombinationQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CombinationTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return CombinationQuery The current query, for fluid interface + * @return ChildCombinationQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(CombinationPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(CombinationTableMap::CREATED_AT); } /** * Order by create date asc * - * @return CombinationQuery The current query, for fluid interface + * @return ChildCombinationQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(CombinationPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(CombinationTableMap::CREATED_AT); } -} + +} // CombinationQuery diff --git a/core/lib/Thelia/Model/om/BaseConfig.php b/core/lib/Thelia/Model/Base/Config.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseConfig.php rename to core/lib/Thelia/Model/Base/Config.php index 9a9e3b851..140cdb82d --- a/core/lib/Thelia/Model/om/BaseConfig.php +++ b/core/lib/Thelia/Model/Base/Config.php @@ -1,53 +1,61 @@ applyDefaultValues(); } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Config instance. If + * obj is an instance of Config, delegates to + * equals(Config). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Config The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Config The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [name] column value. * - * @return string + * @return string */ public function getName() { + return $this->name; } /** * Get the [value] column value. * - * @return string + * @return string */ public function getValue() { + return $this->value; } /** * Get the [secured] column value. * - * @return int + * @return int */ public function getSecured() { + return $this->secured; } /** * Get the [hidden] column value. * - * @return int + * @return int */ public function getHidden() { + return $this->hidden; } @@ -215,97 +462,57 @@ abstract class BaseConfig extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Config The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = ConfigPeer::ID; + $this->modifiedColumns[] = ConfigTableMap::ID; } @@ -315,18 +522,18 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Set the value of [name] column. * - * @param string $v new value - * @return Config The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Config The current object (for fluent API support) */ public function setName($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->name !== $v) { $this->name = $v; - $this->modifiedColumns[] = ConfigPeer::NAME; + $this->modifiedColumns[] = ConfigTableMap::NAME; } @@ -336,18 +543,18 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Set the value of [value] column. * - * @param string $v new value - * @return Config The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Config The current object (for fluent API support) */ public function setValue($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->value !== $v) { $this->value = $v; - $this->modifiedColumns[] = ConfigPeer::VALUE; + $this->modifiedColumns[] = ConfigTableMap::VALUE; } @@ -357,18 +564,18 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Set the value of [secured] column. * - * @param int $v new value - * @return Config The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Config The current object (for fluent API support) */ public function setSecured($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->secured !== $v) { $this->secured = $v; - $this->modifiedColumns[] = ConfigPeer::SECURED; + $this->modifiedColumns[] = ConfigTableMap::SECURED; } @@ -378,18 +585,18 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Set the value of [hidden] column. * - * @param int $v new value - * @return Config The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Config The current object (for fluent API support) */ public function setHidden($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->hidden !== $v) { $this->hidden = $v; - $this->modifiedColumns[] = ConfigPeer::HIDDEN; + $this->modifiedColumns[] = ConfigTableMap::HIDDEN; } @@ -399,19 +606,17 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Config The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ConfigTableMap::CREATED_AT; } } // if either are not null @@ -422,19 +627,17 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Config The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ConfigTableMap::UPDATED_AT; } } // if either are not null @@ -460,7 +663,7 @@ abstract class BaseConfig extends BaseObject implements Persistent return false; } - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -472,23 +675,47 @@ abstract class BaseConfig extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ConfigTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ConfigTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; + $this->name = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ConfigTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $this->value = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ConfigTableMap::translateFieldName('Secured', TableMap::TYPE_PHPNAME, $indexType)]; + $this->secured = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ConfigTableMap::translateFieldName('Hidden', TableMap::TYPE_PHPNAME, $indexType)]; + $this->hidden = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ConfigTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ConfigTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -496,11 +723,11 @@ abstract class BaseConfig extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = ConfigPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 7; // 7 = ConfigTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Config object", $e); + throw new PropelException("Error populating \Thelia\Model\Config object", 0, $e); } } @@ -519,7 +746,6 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -527,12 +753,12 @@ abstract class BaseConfig extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -543,19 +769,19 @@ abstract class BaseConfig extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ConfigTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildConfigQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -567,26 +793,25 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Config::setDeleted() + * @see Config::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ConfigQuery::create() + $deleteQuery = ChildConfigQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -611,20 +836,19 @@ abstract class BaseConfig extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -634,16 +858,16 @@ abstract class BaseConfig extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(ConfigPeer::CREATED_AT)) { + if (!$this->isColumnModified(ConfigTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(ConfigPeer::UPDATED_AT)) { + if (!$this->isColumnModified(ConfigTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ConfigPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(ConfigTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -655,7 +879,7 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - ConfigPeer::addInstanceToPool($this); + ConfigTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -674,12 +898,12 @@ abstract class BaseConfig extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -698,15 +922,15 @@ abstract class BaseConfig extends BaseObject implements Persistent if ($this->configI18nsScheduledForDeletion !== null) { if (!$this->configI18nsScheduledForDeletion->isEmpty()) { - ConfigI18nQuery::create() + \Thelia\Model\ConfigI18nQuery::create() ->filterByPrimaryKeys($this->configI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->configI18nsScheduledForDeletion = null; } } - if ($this->collConfigI18ns !== null) { - foreach ($this->collConfigI18ns as $referrerFK) { + if ($this->collConfigI18ns !== null) { + foreach ($this->collConfigI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -723,46 +947,46 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = ConfigPeer::ID; + $this->modifiedColumns[] = ConfigTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConfigPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConfigTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ConfigPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(ConfigTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ConfigPeer::NAME)) { - $modifiedColumns[':p' . $index++] = '`name`'; + if ($this->isColumnModified(ConfigTableMap::NAME)) { + $modifiedColumns[':p' . $index++] = 'NAME'; } - if ($this->isColumnModified(ConfigPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`value`'; + if ($this->isColumnModified(ConfigTableMap::VALUE)) { + $modifiedColumns[':p' . $index++] = 'VALUE'; } - if ($this->isColumnModified(ConfigPeer::SECURED)) { - $modifiedColumns[':p' . $index++] = '`secured`'; + if ($this->isColumnModified(ConfigTableMap::SECURED)) { + $modifiedColumns[':p' . $index++] = 'SECURED'; } - if ($this->isColumnModified(ConfigPeer::HIDDEN)) { - $modifiedColumns[':p' . $index++] = '`hidden`'; + if ($this->isColumnModified(ConfigTableMap::HIDDEN)) { + $modifiedColumns[':p' . $index++] = 'HIDDEN'; } - if ($this->isColumnModified(ConfigPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(ConfigTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(ConfigPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(ConfigTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `config` (%s) VALUES (%s)', + 'INSERT INTO config (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -771,39 +995,39 @@ abstract class BaseConfig extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`name`': + case 'NAME': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; - case '`value`': + case 'VALUE': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case '`secured`': + case 'SECURED': $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT); break; - case '`hidden`': + case 'HIDDEN': $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -813,112 +1037,32 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = ConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ConfigTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -928,7 +1072,7 @@ abstract class BaseConfig extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -967,22 +1111,22 @@ abstract class BaseConfig extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = ConfigTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getName(), @@ -992,6 +1136,12 @@ abstract class BaseConfig extends BaseObject implements Persistent $keys[5] => $this->getCreatedAt(), $keys[6] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collConfigI18ns) { $result['ConfigI18ns'] = $this->collConfigI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1004,27 +1154,27 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = ConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ConfigTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1063,17 +1213,17 @@ abstract class BaseConfig extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = ConfigPeer::getFieldNames($keyType); + $keys = ConfigTableMap::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]]); @@ -1091,15 +1241,15 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(ConfigPeer::DATABASE_NAME); + $criteria = new Criteria(ConfigTableMap::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); + if ($this->isColumnModified(ConfigTableMap::ID)) $criteria->add(ConfigTableMap::ID, $this->id); + if ($this->isColumnModified(ConfigTableMap::NAME)) $criteria->add(ConfigTableMap::NAME, $this->name); + if ($this->isColumnModified(ConfigTableMap::VALUE)) $criteria->add(ConfigTableMap::VALUE, $this->value); + if ($this->isColumnModified(ConfigTableMap::SECURED)) $criteria->add(ConfigTableMap::SECURED, $this->secured); + if ($this->isColumnModified(ConfigTableMap::HIDDEN)) $criteria->add(ConfigTableMap::HIDDEN, $this->hidden); + if ($this->isColumnModified(ConfigTableMap::CREATED_AT)) $criteria->add(ConfigTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ConfigTableMap::UPDATED_AT)) $criteria->add(ConfigTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1114,15 +1264,15 @@ abstract class BaseConfig extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(ConfigPeer::DATABASE_NAME); - $criteria->add(ConfigPeer::ID, $this->id); + $criteria = new Criteria(ConfigTableMap::DATABASE_NAME); + $criteria->add(ConfigTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1132,7 +1282,7 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1156,9 +1306,9 @@ abstract class BaseConfig extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1170,12 +1320,10 @@ abstract class BaseConfig extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1183,8 +1331,6 @@ abstract class BaseConfig extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1201,8 +1347,8 @@ abstract class BaseConfig extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Config Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1215,37 +1361,19 @@ abstract class BaseConfig extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('ConfigI18n' == $relationName) { - $this->initConfigI18ns(); + return $this->initConfigI18ns(); } } @@ -1255,21 +1383,16 @@ abstract class BaseConfig extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collConfigI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collConfigI18ns collection loaded partially - * - * @return void + * Reset is the collConfigI18ns collection loaded partially. */ public function resetPartialConfigI18ns($v = true) { @@ -1283,7 +1406,7 @@ abstract class BaseConfig extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1293,25 +1416,25 @@ abstract class BaseConfig extends BaseObject implements Persistent if (null !== $this->collConfigI18ns && !$overrideExisting) { return; } - $this->collConfigI18ns = new PropelObjectCollection(); - $this->collConfigI18ns->setModel('ConfigI18n'); + $this->collConfigI18ns = new ObjectCollection(); + $this->collConfigI18ns->setModel('\Thelia\Model\ConfigI18n'); } /** - * Gets an array of ConfigI18n objects which contain a foreign key that references this object. + * Gets an array of ChildConfigI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildConfig is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildConfigI18n[] List of ChildConfigI18n objects * @throws PropelException */ - public function getConfigI18ns($criteria = null, PropelPDO $con = null) + public function getConfigI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collConfigI18nsPartial && !$this->isNew(); if (null === $this->collConfigI18ns || null !== $criteria || $partial) { @@ -1319,29 +1442,31 @@ abstract class BaseConfig extends BaseObject implements Persistent // return empty collection $this->initConfigI18ns(); } else { - $collConfigI18ns = ConfigI18nQuery::create(null, $criteria) + $collConfigI18ns = ChildConfigI18nQuery::create(null, $criteria) ->filterByConfig($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collConfigI18nsPartial && count($collConfigI18ns)) { - $this->initConfigI18ns(false); + $this->initConfigI18ns(false); - foreach($collConfigI18ns as $obj) { - if (false == $this->collConfigI18ns->contains($obj)) { - $this->collConfigI18ns->append($obj); + foreach ($collConfigI18ns as $obj) { + if (false == $this->collConfigI18ns->contains($obj)) { + $this->collConfigI18ns->append($obj); + } } - } - $this->collConfigI18nsPartial = true; + $this->collConfigI18nsPartial = true; } $collConfigI18ns->getInternalIterator()->rewind(); + return $collConfigI18ns; } - if($partial && $this->collConfigI18ns) { - foreach($this->collConfigI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collConfigI18ns) { + foreach ($this->collConfigI18ns as $obj) { + if ($obj->isNew()) { $collConfigI18ns[] = $obj; } } @@ -1361,15 +1486,19 @@ abstract class BaseConfig extends BaseObject implements Persistent * It will 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) + * @param Collection $configI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildConfig The current object (for fluent API support) */ - public function setConfigI18ns(PropelCollection $configI18ns, PropelPDO $con = null) + public function setConfigI18ns(Collection $configI18ns, ConnectionInterface $con = null) { $configI18nsToDelete = $this->getConfigI18ns(new Criteria(), $con)->diff($configI18ns); - $this->configI18nsScheduledForDeletion = unserialize(serialize($configI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->configI18nsScheduledForDeletion = clone $configI18nsToDelete; foreach ($configI18nsToDelete as $configI18nRemoved) { $configI18nRemoved->setConfig(null); @@ -1389,13 +1518,13 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Returns the number of related ConfigI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ConfigI18n objects. * @throws PropelException */ - public function countConfigI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countConfigI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collConfigI18nsPartial && !$this->isNew(); if (null === $this->collConfigI18ns || null !== $criteria || $partial) { @@ -1403,10 +1532,11 @@ abstract class BaseConfig extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getConfigI18ns()); } - $query = ConfigI18nQuery::create(null, $criteria); + + $query = ChildConfigI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1420,13 +1550,13 @@ abstract class BaseConfig extends BaseObject implements Persistent } /** - * Method called to associate a ConfigI18n object to this object - * through the ConfigI18n foreign key attribute. + * Method called to associate a ChildConfigI18n object to this object + * through the ChildConfigI18n foreign key attribute. * - * @param ConfigI18n $l ConfigI18n - * @return Config The current object (for fluent API support) + * @param ChildConfigI18n $l ChildConfigI18n + * @return \Thelia\Model\Config The current object (for fluent API support) */ - public function addConfigI18n(ConfigI18n $l) + public function addConfigI18n(ChildConfigI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1436,6 +1566,7 @@ abstract class BaseConfig extends BaseObject implements Persistent $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); } @@ -1444,7 +1575,7 @@ abstract class BaseConfig extends BaseObject implements Persistent } /** - * @param ConfigI18n $configI18n The configI18n object to add. + * @param ConfigI18n $configI18n The configI18n object to add. */ protected function doAddConfigI18n($configI18n) { @@ -1453,8 +1584,8 @@ abstract class BaseConfig extends BaseObject implements Persistent } /** - * @param ConfigI18n $configI18n The configI18n object to remove. - * @return Config The current object (for fluent API support) + * @param ConfigI18n $configI18n The configI18n object to remove. + * @return ChildConfig The current object (for fluent API support) */ public function removeConfigI18n($configI18n) { @@ -1484,8 +1615,6 @@ abstract class BaseConfig extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1498,51 +1627,38 @@ abstract class BaseConfig extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collConfigI18ns) { foreach ($this->collConfigI18ns as $o) { $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collConfigI18ns instanceof PropelCollection) { + if ($this->collConfigI18ns instanceof Collection) { $this->collConfigI18ns->clearIterator(); } $this->collConfigI18ns = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(ConfigTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1550,11 +1666,11 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * 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) + * @return ChildConfig The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = ConfigPeer::UPDATED_AT; + $this->modifiedColumns[] = ConfigTableMap::UPDATED_AT; return $this; } @@ -1566,9 +1682,9 @@ abstract class BaseConfig extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Config The current object (for fluent API support) + * @return ChildConfig The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1589,10 +1705,10 @@ abstract class BaseConfig extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return ConfigI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildConfigI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collConfigI18ns) { @@ -1605,10 +1721,10 @@ abstract class BaseConfig extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new ConfigI18n(); + $translation = new ChildConfigI18n(); $translation->setLocale($locale); } else { - $translation = ConfigI18nQuery::create() + $translation = ChildConfigI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -1623,14 +1739,14 @@ abstract class BaseConfig extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Config The current object (for fluent API support) + * @return ChildConfig The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - ConfigI18nQuery::create() + ChildConfigI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -1650,10 +1766,10 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return ConfigI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildConfigI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -1662,7 +1778,7 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -1673,8 +1789,8 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ConfigI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -1686,7 +1802,7 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -1697,8 +1813,8 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ConfigI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -1710,7 +1826,7 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -1721,8 +1837,8 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ConfigI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -1734,7 +1850,7 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -1745,8 +1861,8 @@ abstract class BaseConfig extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ConfigI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -1754,4 +1870,122 @@ abstract class BaseConfig extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/ConfigI18n.php b/core/lib/Thelia/Model/Base/ConfigI18n.php new file mode 100644 index 000000000..e73e27514 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ConfigI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ConfigI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ConfigI18n instance. If + * obj is an instance of ConfigI18n, delegates to + * equals(ConfigI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ConfigI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ConfigI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\ConfigI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ConfigI18nTableMap::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 \Thelia\Model\ConfigI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ConfigI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ConfigI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ConfigI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ConfigI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ConfigI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ConfigI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ConfigI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ConfigI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ConfigI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ConfigI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ConfigI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ConfigI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ConfigI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ConfigI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ConfigI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ConfigI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ConfigI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ConfigI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildConfigI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aConfig = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ConfigI18n::setDeleted() + * @see ConfigI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildConfigI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME); + } + + $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); + ConfigI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ConfigI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ConfigI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ConfigI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ConfigI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ConfigI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ConfigI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ConfigI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ConfigI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ConfigI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ConfigI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ConfigI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ConfigI18nTableMap::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(ConfigI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ConfigI18nTableMap::ID)) $criteria->add(ConfigI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ConfigI18nTableMap::LOCALE)) $criteria->add(ConfigI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ConfigI18nTableMap::TITLE)) $criteria->add(ConfigI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ConfigI18nTableMap::DESCRIPTION)) $criteria->add(ConfigI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ConfigI18nTableMap::CHAPO)) $criteria->add(ConfigI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ConfigI18nTableMap::POSTSCRIPTUM)) $criteria->add(ConfigI18nTableMap::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(ConfigI18nTableMap::DATABASE_NAME); + $criteria->add(ConfigI18nTableMap::ID, $this->id); + $criteria->add(ConfigI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildConfig object. + * + * @param ChildConfig $v + * @return \Thelia\Model\ConfigI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setConfig(ChildConfig $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 ChildConfig object, it will not be re-added. + if ($v !== null) { + $v->addConfigI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildConfig object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildConfig The associated ChildConfig object. + * @throws PropelException + */ + public function getConfig(ConnectionInterface $con = null) + { + if ($this->aConfig === null && ($this->id !== null)) { + $this->aConfig = ChildConfigQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aConfig = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ConfigI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseConfigI18nQuery.php b/core/lib/Thelia/Model/Base/ConfigI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseConfigI18nQuery.php rename to core/lib/Thelia/Model/Base/ConfigI18nQuery.php index f53cc2de2..bc231b05c --- a/core/lib/Thelia/Model/om/BaseConfigI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ConfigI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ConfigI18n|ConfigI18n[]|mixed the result, formatted by the current formatter + * @return ChildConfigI18n|array|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 + if ((null !== ($obj = ConfigI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ConfigI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ConfigI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ConfigI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildConfigI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `config_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseConfigI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ConfigI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildConfigI18n(); $obj->hydrate($row); - ConfigI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ConfigI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ConfigI18n|ConfigI18n[]|mixed the result, formatted by the current formatter + * @return ChildConfigI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ConfigI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ConfigI18nQuery The current query, for fluid interface + * @return ChildConfigI18nQuery 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); + $this->addUsingAlias(ConfigI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ConfigI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ConfigI18nQuery The current query, for fluid interface + * @return ChildConfigI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseConfigI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(ConfigI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ConfigI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByConfig() @@ -270,18 +266,18 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * 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 + * @return ChildConfigI18nQuery 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); + $this->addUsingAlias(ConfigI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ConfigI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ConfigI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(ConfigI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * 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 + * @return ChildConfigI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(ConfigI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * 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 + * @return ChildConfigI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(ConfigI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * 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 + * @return ChildConfigI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(ConfigI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * 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 + * @return ChildConfigI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(ConfigI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * 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 + * @return ChildConfigI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseConfigI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(ConfigI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Config object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Config|ObjectCollection $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. + * @return ChildConfigI18nQuery The current query, for fluid interface */ public function filterByConfig($config, $comparison = null) { - if ($config instanceof Config) { + if ($config instanceof \Thelia\Model\Config) { return $this - ->addUsingAlias(ConfigI18nPeer::ID, $config->getId(), $comparison); - } elseif ($config instanceof PropelObjectCollection) { + ->addUsingAlias(ConfigI18nTableMap::ID, $config->getId(), $comparison); + } elseif ($config instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ConfigI18nPeer::ID, $config->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ConfigI18nTableMap::ID, $config->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByConfig() only accepts arguments of type Config or PropelCollection'); + throw new PropelException('filterByConfig() only accepts arguments of type \Thelia\Model\Config or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria * @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 + * @return ChildConfigI18nQuery The current query, for fluid interface */ public function joinConfig($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseConfigI18nQuery extends ModelCriteria /** * Use the Config relation Config object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseConfigI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param ConfigI18n $configI18n Object to remove from the list of results + * @param ChildConfigI18n $configI18n Object to remove from the list of results * - * @return ConfigI18nQuery The current query, for fluid interface + * @return ChildConfigI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(ConfigI18nTableMap::ID), $configI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ConfigI18nTableMap::LOCALE), $configI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the config_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ConfigI18nTableMap::clearInstancePool(); + ConfigI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildConfigI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildConfigI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ConfigI18nTableMap::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(); + + + ConfigI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ConfigI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ConfigI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseConfigQuery.php b/core/lib/Thelia/Model/Base/ConfigQuery.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseConfigQuery.php rename to core/lib/Thelia/Model/Base/ConfigQuery.php index 808e6e5bd..b2ddc3409 --- a/core/lib/Thelia/Model/om/BaseConfigQuery.php +++ b/core/lib/Thelia/Model/Base/ConfigQuery.php @@ -1,99 +1,100 @@ setModelAlias($modelAlias); } @@ -114,21 +115,21 @@ abstract class BaseConfigQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Config|Config[]|mixed the result, formatted by the current formatter + * @return ChildConfig|array|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 + if ((null !== ($obj = ConfigTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ConfigTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -140,46 +141,31 @@ abstract class BaseConfigQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Config A model object, or null if the key is not found - * @throws PropelException + * @return ChildConfig A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `name`, `value`, `secured`, `hidden`, `created_at`, `updated_at` FROM `config` WHERE `id` = :p0'; + $sql = 'SELECT ID, NAME, VALUE, SECURED, HIDDEN, CREATED_AT, UPDATED_AT FROM config WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Config(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildConfig(); $obj->hydrate($row); - ConfigPeer::addInstanceToPool($obj, (string) $key); + ConfigTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -190,19 +176,19 @@ abstract class BaseConfigQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Config|Config[]|mixed the result, formatted by the current formatter + * @return ChildConfig|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -211,22 +197,22 @@ abstract class BaseConfigQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Config[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -234,12 +220,12 @@ abstract class BaseConfigQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ConfigQuery The current query, for fluid interface + * @return ChildConfigQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(ConfigPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(ConfigTableMap::ID, $key, Criteria::EQUAL); } /** @@ -247,12 +233,12 @@ abstract class BaseConfigQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ConfigQuery The current query, for fluid interface + * @return ChildConfigQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(ConfigPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(ConfigTableMap::ID, $keys, Criteria::IN); } /** @@ -262,8 +248,7 @@ abstract class BaseConfigQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -272,18 +257,18 @@ abstract class BaseConfigQuery extends ModelCriteria * 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 + * @return ChildConfigQuery 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); + $this->addUsingAlias(ConfigTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ConfigPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ConfigTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -294,7 +279,7 @@ abstract class BaseConfigQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigPeer::ID, $id, $comparison); + return $this->addUsingAlias(ConfigTableMap::ID, $id, $comparison); } /** @@ -310,7 +295,7 @@ abstract class BaseConfigQuery extends ModelCriteria * 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 + * @return ChildConfigQuery The current query, for fluid interface */ public function filterByName($name = null, $comparison = null) { @@ -323,7 +308,7 @@ abstract class BaseConfigQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigPeer::NAME, $name, $comparison); + return $this->addUsingAlias(ConfigTableMap::NAME, $name, $comparison); } /** @@ -339,7 +324,7 @@ abstract class BaseConfigQuery extends ModelCriteria * 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 + * @return ChildConfigQuery The current query, for fluid interface */ public function filterByValue($value = null, $comparison = null) { @@ -352,7 +337,7 @@ abstract class BaseConfigQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigPeer::VALUE, $value, $comparison); + return $this->addUsingAlias(ConfigTableMap::VALUE, $value, $comparison); } /** @@ -362,8 +347,7 @@ abstract class BaseConfigQuery extends ModelCriteria * * $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 + * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12 * * * @param mixed $secured The value to use as filter. @@ -372,18 +356,18 @@ abstract class BaseConfigQuery extends ModelCriteria * 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 + * @return ChildConfigQuery 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); + $this->addUsingAlias(ConfigTableMap::SECURED, $secured['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($secured['max'])) { - $this->addUsingAlias(ConfigPeer::SECURED, $secured['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ConfigTableMap::SECURED, $secured['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -394,7 +378,7 @@ abstract class BaseConfigQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigPeer::SECURED, $secured, $comparison); + return $this->addUsingAlias(ConfigTableMap::SECURED, $secured, $comparison); } /** @@ -404,8 +388,7 @@ abstract class BaseConfigQuery extends ModelCriteria * * $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 + * $query->filterByHidden(array('min' => 12)); // WHERE hidden > 12 * * * @param mixed $hidden The value to use as filter. @@ -414,18 +397,18 @@ abstract class BaseConfigQuery extends ModelCriteria * 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 + * @return ChildConfigQuery 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); + $this->addUsingAlias(ConfigTableMap::HIDDEN, $hidden['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($hidden['max'])) { - $this->addUsingAlias(ConfigPeer::HIDDEN, $hidden['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ConfigTableMap::HIDDEN, $hidden['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -436,7 +419,7 @@ abstract class BaseConfigQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigPeer::HIDDEN, $hidden, $comparison); + return $this->addUsingAlias(ConfigTableMap::HIDDEN, $hidden, $comparison); } /** @@ -457,18 +440,18 @@ abstract class BaseConfigQuery extends ModelCriteria * 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 + * @return ChildConfigQuery 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); + $this->addUsingAlias(ConfigTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ConfigPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ConfigTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -479,7 +462,7 @@ abstract class BaseConfigQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ConfigTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -500,18 +483,18 @@ abstract class BaseConfigQuery extends ModelCriteria * 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 + * @return ChildConfigQuery 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); + $this->addUsingAlias(ConfigTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ConfigPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ConfigTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -522,30 +505,29 @@ abstract class BaseConfigQuery extends ModelCriteria } } - return $this->addUsingAlias(ConfigPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ConfigTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related ConfigI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ConfigI18n|ObjectCollection $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. + * @return ChildConfigQuery The current query, for fluid interface */ public function filterByConfigI18n($configI18n, $comparison = null) { - if ($configI18n instanceof ConfigI18n) { + if ($configI18n instanceof \Thelia\Model\ConfigI18n) { return $this - ->addUsingAlias(ConfigPeer::ID, $configI18n->getId(), $comparison); - } elseif ($configI18n instanceof PropelObjectCollection) { + ->addUsingAlias(ConfigTableMap::ID, $configI18n->getId(), $comparison); + } elseif ($configI18n instanceof ObjectCollection) { return $this ->useConfigI18nQuery() ->filterByPrimaryKeys($configI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByConfigI18n() only accepts arguments of type ConfigI18n or PropelCollection'); + throw new PropelException('filterByConfigI18n() only accepts arguments of type \Thelia\Model\ConfigI18n or Collection'); } } @@ -555,7 +537,7 @@ abstract class BaseConfigQuery extends ModelCriteria * @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 + * @return ChildConfigQuery The current query, for fluid interface */ public function joinConfigI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -584,7 +566,7 @@ abstract class BaseConfigQuery extends ModelCriteria /** * Use the ConfigI18n relation ConfigI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -602,19 +584,94 @@ abstract class BaseConfigQuery extends ModelCriteria /** * Exclude object from result * - * @param Config $config Object to remove from the list of results + * @param ChildConfig $config Object to remove from the list of results * - * @return ConfigQuery The current query, for fluid interface + * @return ChildConfigQuery The current query, for fluid interface */ public function prune($config = null) { if ($config) { - $this->addUsingAlias(ConfigPeer::ID, $config->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(ConfigTableMap::ID, $config->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the config table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ConfigTableMap::clearInstancePool(); + ConfigTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildConfig or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildConfig object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ConfigTableMap::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(); + + + ConfigTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ConfigTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -622,31 +679,11 @@ abstract class BaseConfigQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ConfigQuery The current query, for fluid interface + * @return ChildConfigQuery 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); + return $this->addUsingAlias(ConfigTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -654,32 +691,53 @@ abstract class BaseConfigQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ConfigQuery The current query, for fluid interface + * @return ChildConfigQuery 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); + return $this->addUsingAlias(ConfigTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildConfigQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ConfigTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildConfigQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ConfigTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ConfigQuery The current query, for fluid interface + * @return ChildConfigQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(ConfigPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(ConfigTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ConfigQuery The current query, for fluid interface + * @return ChildConfigQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(ConfigPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(ConfigTableMap::CREATED_AT); } + // i18n behavior /** @@ -689,9 +747,9 @@ abstract class BaseConfigQuery extends ModelCriteria * @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 + * @return ChildConfigQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ConfigI18n'; @@ -707,9 +765,9 @@ abstract class BaseConfigQuery extends ModelCriteria * @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 + * @return ChildConfigQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -728,13 +786,13 @@ abstract class BaseConfigQuery extends ModelCriteria * @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 + * @return ChildConfigI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ConfigI18n', 'Thelia\Model\ConfigI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'ConfigI18n', '\Thelia\Model\ConfigI18nQuery'); } -} +} // ConfigQuery diff --git a/core/lib/Thelia/Model/om/BaseContent.php b/core/lib/Thelia/Model/Base/Content.php old mode 100755 new mode 100644 similarity index 61% rename from core/lib/Thelia/Model/om/BaseContent.php rename to core/lib/Thelia/Model/Base/Content.php index a7fbcb3a4..eec31f072 --- a/core/lib/Thelia/Model/om/BaseContent.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -1,68 +1,76 @@ applyDefaultValues(); } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Content instance. If + * obj is an instance of Content, delegates to + * equals(Content). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Content The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Content The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [visible] column value. * - * @return int + * @return int */ public function getVisible() { + return $this->visible; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -305,89 +550,50 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version] column value. * - * @return int + * @return int */ public function getVersion() { + return $this->version; } @@ -395,67 +601,48 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getVersionCreatedAt($format = NULL) { - 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; + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version_created_by] column value. * - * @return string + * @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) + * @param int $v new value + * @return \Thelia\Model\Content The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = ContentPeer::ID; + $this->modifiedColumns[] = ContentTableMap::ID; } @@ -465,18 +652,18 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Set the value of [visible] column. * - * @param int $v new value - * @return Content The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Content The current object (for fluent API support) */ public function setVisible($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->visible !== $v) { $this->visible = $v; - $this->modifiedColumns[] = ContentPeer::VISIBLE; + $this->modifiedColumns[] = ContentTableMap::VISIBLE; } @@ -486,18 +673,18 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return Content The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Content The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = ContentPeer::POSITION; + $this->modifiedColumns[] = ContentTableMap::POSITION; } @@ -507,19 +694,17 @@ abstract class BaseContent extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Content The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ContentTableMap::CREATED_AT; } } // if either are not null @@ -530,19 +715,17 @@ abstract class BaseContent extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Content The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ContentTableMap::UPDATED_AT; } } // if either are not null @@ -553,18 +736,18 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Set the value of [version] column. * - * @param int $v new value - * @return Content The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Content The current object (for fluent API support) */ public function setVersion($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->version !== $v) { $this->version = $v; - $this->modifiedColumns[] = ContentPeer::VERSION; + $this->modifiedColumns[] = ContentTableMap::VERSION; } @@ -574,19 +757,17 @@ abstract class BaseContent extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Content The current object (for fluent API support) */ public function setVersionCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = ContentTableMap::VERSION_CREATED_AT; } } // if either are not null @@ -597,18 +778,18 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Set the value of [version_created_by] column. * - * @param string $v new value - * @return Content The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Content The current object (for fluent API support) */ public function setVersionCreatedBy($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->version_created_by !== $v) { $this->version_created_by = $v; - $this->modifiedColumns[] = ContentPeer::VERSION_CREATED_BY; + $this->modifiedColumns[] = ContentTableMap::VERSION_CREATED_BY; } @@ -629,7 +810,7 @@ abstract class BaseContent extends BaseObject implements Persistent return false; } - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -641,24 +822,53 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ContentTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ContentTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -666,11 +876,11 @@ abstract class BaseContent extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = ContentPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 8; // 8 = ContentTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Content object", $e); + throw new PropelException("Error populating \Thelia\Model\Content object", 0, $e); } } @@ -689,7 +899,6 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -697,12 +906,12 @@ abstract class BaseContent extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -713,19 +922,19 @@ abstract class BaseContent extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ContentTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildContentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -750,26 +959,25 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Content::setDeleted() + * @see Content::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ContentQuery::create() + $deleteQuery = ChildContentQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -794,20 +1002,19 @@ abstract class BaseContent extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -817,7 +1024,7 @@ abstract class BaseContent extends BaseObject implements Persistent // versionable behavior if ($this->isVersioningNecessary()) { $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1); - if (!$this->isColumnModified(ContentPeer::VERSION_CREATED_AT)) { + if (!$this->isColumnModified(ContentTableMap::VERSION_CREATED_AT)) { $this->setVersionCreatedAt(time()); } $createVersion = true; // for postSave hook @@ -825,16 +1032,16 @@ abstract class BaseContent extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(ContentPeer::CREATED_AT)) { + if (!$this->isColumnModified(ContentTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(ContentPeer::UPDATED_AT)) { + if (!$this->isColumnModified(ContentTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ContentPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(ContentTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -850,7 +1057,7 @@ abstract class BaseContent extends BaseObject implements Persistent if (isset($createVersion)) { $this->addVersion($con); } - ContentPeer::addInstanceToPool($this); + ContentTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -869,12 +1076,12 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -894,10 +1101,11 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->foldersScheduledForDeletion !== null) { if (!$this->foldersScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->foldersScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($pk, $remotePk); } + ContentFolderQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -919,16 +1127,15 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->contentAssocsScheduledForDeletion !== null) { if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { - // need to save related object because we set the relation to null - $contentAssoc->save($con); - } + \Thelia\Model\ContentAssocQuery::create() + ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->contentAssocsScheduledForDeletion = null; } } - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { + if ($this->collContentAssocs !== null) { + foreach ($this->collContentAssocs as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -937,16 +1144,15 @@ abstract class BaseContent extends BaseObject implements Persistent 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); - } + \Thelia\Model\ImageQuery::create() + ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->imagesScheduledForDeletion = null; } } - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { + if ($this->collImages !== null) { + foreach ($this->collImages as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -955,16 +1161,15 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->documentsScheduledForDeletion !== null) { if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } + \Thelia\Model\DocumentQuery::create() + ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->documentsScheduledForDeletion = null; } } - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -973,16 +1178,15 @@ abstract class BaseContent extends BaseObject implements Persistent 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); - } + \Thelia\Model\RewritingQuery::create() + ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->rewritingsScheduledForDeletion = null; } } - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { + if ($this->collRewritings !== null) { + foreach ($this->collRewritings as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -991,15 +1195,15 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->contentFoldersScheduledForDeletion !== null) { if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { - ContentFolderQuery::create() + \Thelia\Model\ContentFolderQuery::create() ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->contentFoldersScheduledForDeletion = null; } } - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { + if ($this->collContentFolders !== null) { + foreach ($this->collContentFolders as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1008,15 +1212,15 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->contentI18nsScheduledForDeletion !== null) { if (!$this->contentI18nsScheduledForDeletion->isEmpty()) { - ContentI18nQuery::create() + \Thelia\Model\ContentI18nQuery::create() ->filterByPrimaryKeys($this->contentI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->contentI18nsScheduledForDeletion = null; } } - if ($this->collContentI18ns !== null) { - foreach ($this->collContentI18ns as $referrerFK) { + if ($this->collContentI18ns !== null) { + foreach ($this->collContentI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1025,15 +1229,15 @@ abstract class BaseContent extends BaseObject implements Persistent if ($this->contentVersionsScheduledForDeletion !== null) { if (!$this->contentVersionsScheduledForDeletion->isEmpty()) { - ContentVersionQuery::create() + \Thelia\Model\ContentVersionQuery::create() ->filterByPrimaryKeys($this->contentVersionsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->contentVersionsScheduledForDeletion = null; } } - if ($this->collContentVersions !== null) { - foreach ($this->collContentVersions as $referrerFK) { + if ($this->collContentVersions !== null) { + foreach ($this->collContentVersions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1050,49 +1254,49 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = ContentPeer::ID; + $this->modifiedColumns[] = ContentTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ContentPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(ContentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ContentPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; + if ($this->isColumnModified(ContentTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; } - if ($this->isColumnModified(ContentPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(ContentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(ContentPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(ContentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(ContentPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(ContentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } - if ($this->isColumnModified(ContentPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`version`'; + if ($this->isColumnModified(ContentTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; } - if ($this->isColumnModified(ContentPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`version_created_at`'; + if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; } - if ($this->isColumnModified(ContentPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`version_created_by`'; + if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_BY)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY'; } $sql = sprintf( - 'INSERT INTO `content` (%s) VALUES (%s)', + 'INSERT INTO content (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1101,28 +1305,28 @@ abstract class BaseContent extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`visible`': + case 'VISIBLE': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version`': + 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); + case 'VERSION_CREATED_AT': + $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version_created_by`': + case 'VERSION_CREATED_BY': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1130,13 +1334,13 @@ abstract class BaseContent extends BaseObject implements Persistent $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -1146,160 +1350,32 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = ContentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1309,7 +1385,7 @@ abstract class BaseContent extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1351,22 +1427,22 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = ContentTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getVisible(), @@ -1377,6 +1453,12 @@ abstract class BaseContent extends BaseObject implements Persistent $keys[6] => $this->getVersionCreatedAt(), $keys[7] => $this->getVersionCreatedBy(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collContentAssocs) { $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1407,27 +1489,27 @@ abstract class BaseContent extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = ContentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ContentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1469,17 +1551,17 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = ContentPeer::getFieldNames($keyType); + $keys = ContentTableMap::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]]); @@ -1498,16 +1580,16 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(ContentPeer::DATABASE_NAME); + $criteria = new Criteria(ContentTableMap::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); + if ($this->isColumnModified(ContentTableMap::ID)) $criteria->add(ContentTableMap::ID, $this->id); + if ($this->isColumnModified(ContentTableMap::VISIBLE)) $criteria->add(ContentTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(ContentTableMap::POSITION)) $criteria->add(ContentTableMap::POSITION, $this->position); + if ($this->isColumnModified(ContentTableMap::CREATED_AT)) $criteria->add(ContentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ContentTableMap::UPDATED_AT)) $criteria->add(ContentTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(ContentTableMap::VERSION)) $criteria->add(ContentTableMap::VERSION, $this->version); + if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_AT)) $criteria->add(ContentTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(ContentTableMap::VERSION_CREATED_BY)) $criteria->add(ContentTableMap::VERSION_CREATED_BY, $this->version_created_by); return $criteria; } @@ -1522,15 +1604,15 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(ContentPeer::DATABASE_NAME); - $criteria->add(ContentPeer::ID, $this->id); + $criteria = new Criteria(ContentTableMap::DATABASE_NAME); + $criteria->add(ContentTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1540,7 +1622,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1564,9 +1646,9 @@ abstract class BaseContent extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1579,12 +1661,10 @@ abstract class BaseContent extends BaseObject implements Persistent $copyObj->setVersionCreatedAt($this->getVersionCreatedAt()); $copyObj->setVersionCreatedBy($this->getVersionCreatedBy()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1628,8 +1708,6 @@ abstract class BaseContent extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1646,8 +1724,8 @@ abstract class BaseContent extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Content Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1660,55 +1738,37 @@ abstract class BaseContent extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('ContentAssoc' == $relationName) { - $this->initContentAssocs(); + return $this->initContentAssocs(); } if ('Image' == $relationName) { - $this->initImages(); + return $this->initImages(); } if ('Document' == $relationName) { - $this->initDocuments(); + return $this->initDocuments(); } if ('Rewriting' == $relationName) { - $this->initRewritings(); + return $this->initRewritings(); } if ('ContentFolder' == $relationName) { - $this->initContentFolders(); + return $this->initContentFolders(); } if ('ContentI18n' == $relationName) { - $this->initContentI18ns(); + return $this->initContentI18ns(); } if ('ContentVersion' == $relationName) { - $this->initContentVersions(); + return $this->initContentVersions(); } } @@ -1718,21 +1778,16 @@ abstract class BaseContent extends BaseObject implements Persistent * This 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) + * @return void * @see addContentAssocs() */ public function clearContentAssocs() { - $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized - $this->collContentAssocsPartial = null; - - return $this; + $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collContentAssocs collection loaded partially - * - * @return void + * Reset is the collContentAssocs collection loaded partially. */ public function resetPartialContentAssocs($v = true) { @@ -1746,7 +1801,7 @@ abstract class BaseContent extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1756,25 +1811,25 @@ abstract class BaseContent extends BaseObject implements Persistent if (null !== $this->collContentAssocs && !$overrideExisting) { return; } - $this->collContentAssocs = new PropelObjectCollection(); - $this->collContentAssocs->setModel('ContentAssoc'); + $this->collContentAssocs = new ObjectCollection(); + $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc'); } /** - * Gets an array of ContentAssoc objects which contain a foreign key that references this object. + * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildContent is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects * @throws PropelException */ - public function getContentAssocs($criteria = null, PropelPDO $con = null) + public function getContentAssocs($criteria = null, ConnectionInterface $con = null) { $partial = $this->collContentAssocsPartial && !$this->isNew(); if (null === $this->collContentAssocs || null !== $criteria || $partial) { @@ -1782,29 +1837,31 @@ abstract class BaseContent extends BaseObject implements Persistent // return empty collection $this->initContentAssocs(); } else { - $collContentAssocs = ContentAssocQuery::create(null, $criteria) + $collContentAssocs = ChildContentAssocQuery::create(null, $criteria) ->filterByContent($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); + $this->initContentAssocs(false); - foreach($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); + foreach ($collContentAssocs as $obj) { + if (false == $this->collContentAssocs->contains($obj)) { + $this->collContentAssocs->append($obj); + } } - } - $this->collContentAssocsPartial = true; + $this->collContentAssocsPartial = true; } $collContentAssocs->getInternalIterator()->rewind(); + return $collContentAssocs; } - if($partial && $this->collContentAssocs) { - foreach($this->collContentAssocs as $obj) { - if($obj->isNew()) { + if ($partial && $this->collContentAssocs) { + foreach ($this->collContentAssocs as $obj) { + if ($obj->isNew()) { $collContentAssocs[] = $obj; } } @@ -1824,15 +1881,16 @@ abstract class BaseContent extends BaseObject implements Persistent * It will 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) + * @param Collection $contentAssocs A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) */ - public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) + public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null) { $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete)); + + $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete; foreach ($contentAssocsToDelete as $contentAssocRemoved) { $contentAssocRemoved->setContent(null); @@ -1852,13 +1910,13 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Returns the number of related ContentAssoc objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ContentAssoc objects. * @throws PropelException */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collContentAssocsPartial && !$this->isNew(); if (null === $this->collContentAssocs || null !== $criteria || $partial) { @@ -1866,10 +1924,11 @@ abstract class BaseContent extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getContentAssocs()); } - $query = ContentAssocQuery::create(null, $criteria); + + $query = ChildContentAssocQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1883,18 +1942,19 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Method called to associate a ContentAssoc object to this object - * through the ContentAssoc foreign key attribute. + * Method called to associate a ChildContentAssoc object to this object + * through the ChildContentAssoc foreign key attribute. * - * @param ContentAssoc $l ContentAssoc - * @return Content The current object (for fluent API support) + * @param ChildContentAssoc $l ChildContentAssoc + * @return \Thelia\Model\Content The current object (for fluent API support) */ - public function addContentAssoc(ContentAssoc $l) + public function addContentAssoc(ChildContentAssoc $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); } @@ -1903,7 +1963,7 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. + * @param ContentAssoc $contentAssoc The contentAssoc object to add. */ protected function doAddContentAssoc($contentAssoc) { @@ -1912,8 +1972,8 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return Content The current object (for fluent API support) + * @param ContentAssoc $contentAssoc The contentAssoc object to remove. + * @return ChildContent The current object (for fluent API support) */ public function removeContentAssoc($contentAssoc) { @@ -1942,15 +2002,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects */ - public function getContentAssocsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getContentAssocsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildContentAssocQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getContentAssocs($query, $con); } @@ -1967,15 +2027,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects */ - public function getContentAssocsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getContentAssocsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildContentAssocQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getContentAssocs($query, $con); } @@ -1986,21 +2046,16 @@ abstract class BaseContent extends BaseObject implements Persistent * This 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) + * @return void * @see addImages() */ public function clearImages() { - $this->collImages = null; // important to set this to null since that means it is uninitialized - $this->collImagesPartial = null; - - return $this; + $this->collImages = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collImages collection loaded partially - * - * @return void + * Reset is the collImages collection loaded partially. */ public function resetPartialImages($v = true) { @@ -2014,7 +2069,7 @@ abstract class BaseContent extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2024,25 +2079,25 @@ abstract class BaseContent extends BaseObject implements Persistent if (null !== $this->collImages && !$overrideExisting) { return; } - $this->collImages = new PropelObjectCollection(); - $this->collImages->setModel('Image'); + $this->collImages = new ObjectCollection(); + $this->collImages->setModel('\Thelia\Model\Image'); } /** - * Gets an array of Image objects which contain a foreign key that references this object. + * Gets an array of ChildImage objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildContent is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildImage[] List of ChildImage objects * @throws PropelException */ - public function getImages($criteria = null, PropelPDO $con = null) + public function getImages($criteria = null, ConnectionInterface $con = null) { $partial = $this->collImagesPartial && !$this->isNew(); if (null === $this->collImages || null !== $criteria || $partial) { @@ -2050,29 +2105,31 @@ abstract class BaseContent extends BaseObject implements Persistent // return empty collection $this->initImages(); } else { - $collImages = ImageQuery::create(null, $criteria) + $collImages = ChildImageQuery::create(null, $criteria) ->filterByContent($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); + $this->initImages(false); - foreach($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); + foreach ($collImages as $obj) { + if (false == $this->collImages->contains($obj)) { + $this->collImages->append($obj); + } } - } - $this->collImagesPartial = true; + $this->collImagesPartial = true; } $collImages->getInternalIterator()->rewind(); + return $collImages; } - if($partial && $this->collImages) { - foreach($this->collImages as $obj) { - if($obj->isNew()) { + if ($partial && $this->collImages) { + foreach ($this->collImages as $obj) { + if ($obj->isNew()) { $collImages[] = $obj; } } @@ -2092,15 +2149,16 @@ abstract class BaseContent extends BaseObject implements Persistent * It will 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) + * @param Collection $images A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) */ - public function setImages(PropelCollection $images, PropelPDO $con = null) + public function setImages(Collection $images, ConnectionInterface $con = null) { $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); + + $this->imagesScheduledForDeletion = $imagesToDelete; foreach ($imagesToDelete as $imageRemoved) { $imageRemoved->setContent(null); @@ -2120,13 +2178,13 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Returns the number of related Image objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Image objects. * @throws PropelException */ - public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collImagesPartial && !$this->isNew(); if (null === $this->collImages || null !== $criteria || $partial) { @@ -2134,10 +2192,11 @@ abstract class BaseContent extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getImages()); } - $query = ImageQuery::create(null, $criteria); + + $query = ChildImageQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2151,18 +2210,19 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Method called to associate a Image object to this object - * through the Image foreign key attribute. + * Method called to associate a ChildImage object to this object + * through the ChildImage foreign key attribute. * - * @param Image $l Image - * @return Content The current object (for fluent API support) + * @param ChildImage $l ChildImage + * @return \Thelia\Model\Content The current object (for fluent API support) */ - public function addImage(Image $l) + public function addImage(ChildImage $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); } @@ -2171,7 +2231,7 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param Image $image The image object to add. + * @param Image $image The image object to add. */ protected function doAddImage($image) { @@ -2180,8 +2240,8 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param Image $image The image object to remove. - * @return Content The current object (for fluent API support) + * @param Image $image The image object to remove. + * @return ChildContent The current object (for fluent API support) */ public function removeImage($image) { @@ -2210,15 +2270,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getImages($query, $con); } @@ -2235,15 +2295,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getImages($query, $con); } @@ -2260,15 +2320,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getImages($query, $con); } @@ -2279,21 +2339,16 @@ abstract class BaseContent extends BaseObject implements Persistent * This 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) + * @return void * @see addDocuments() */ public function clearDocuments() { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - - return $this; + $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collDocuments collection loaded partially - * - * @return void + * Reset is the collDocuments collection loaded partially. */ public function resetPartialDocuments($v = true) { @@ -2307,7 +2362,7 @@ abstract class BaseContent extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2317,25 +2372,25 @@ abstract class BaseContent extends BaseObject implements Persistent if (null !== $this->collDocuments && !$overrideExisting) { return; } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); + $this->collDocuments = new ObjectCollection(); + $this->collDocuments->setModel('\Thelia\Model\Document'); } /** - * Gets an array of Document objects which contain a foreign key that references this object. + * Gets an array of ChildDocument objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildContent is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildDocument[] List of ChildDocument objects * @throws PropelException */ - public function getDocuments($criteria = null, PropelPDO $con = null) + public function getDocuments($criteria = null, ConnectionInterface $con = null) { $partial = $this->collDocumentsPartial && !$this->isNew(); if (null === $this->collDocuments || null !== $criteria || $partial) { @@ -2343,29 +2398,31 @@ abstract class BaseContent extends BaseObject implements Persistent // return empty collection $this->initDocuments(); } else { - $collDocuments = DocumentQuery::create(null, $criteria) + $collDocuments = ChildDocumentQuery::create(null, $criteria) ->filterByContent($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); + $this->initDocuments(false); - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); + foreach ($collDocuments as $obj) { + if (false == $this->collDocuments->contains($obj)) { + $this->collDocuments->append($obj); + } } - } - $this->collDocumentsPartial = true; + $this->collDocumentsPartial = true; } $collDocuments->getInternalIterator()->rewind(); + return $collDocuments; } - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { + if ($partial && $this->collDocuments) { + foreach ($this->collDocuments as $obj) { + if ($obj->isNew()) { $collDocuments[] = $obj; } } @@ -2385,15 +2442,16 @@ abstract class BaseContent extends BaseObject implements Persistent * It will 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) + * @param Collection $documents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) + public function setDocuments(Collection $documents, ConnectionInterface $con = null) { $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); + + $this->documentsScheduledForDeletion = $documentsToDelete; foreach ($documentsToDelete as $documentRemoved) { $documentRemoved->setContent(null); @@ -2413,13 +2471,13 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Returns the number of related Document objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Document objects. * @throws PropelException */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collDocumentsPartial && !$this->isNew(); if (null === $this->collDocuments || null !== $criteria || $partial) { @@ -2427,10 +2485,11 @@ abstract class BaseContent extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getDocuments()); } - $query = DocumentQuery::create(null, $criteria); + + $query = ChildDocumentQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2444,18 +2503,19 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. + * Method called to associate a ChildDocument object to this object + * through the ChildDocument foreign key attribute. * - * @param Document $l Document - * @return Content The current object (for fluent API support) + * @param ChildDocument $l ChildDocument + * @return \Thelia\Model\Content The current object (for fluent API support) */ - public function addDocument(Document $l) + public function addDocument(ChildDocument $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); } @@ -2464,7 +2524,7 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param Document $document The document object to add. + * @param Document $document The document object to add. */ protected function doAddDocument($document) { @@ -2473,8 +2533,8 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param Document $document The document object to remove. - * @return Content The current object (for fluent API support) + * @param Document $document The document object to remove. + * @return ChildContent The current object (for fluent API support) */ public function removeDocument($document) { @@ -2503,15 +2563,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getDocuments($query, $con); } @@ -2528,15 +2588,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getDocuments($query, $con); } @@ -2553,15 +2613,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getDocuments($query, $con); } @@ -2572,21 +2632,16 @@ abstract class BaseContent extends BaseObject implements Persistent * This 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) + * @return void * @see addRewritings() */ public function clearRewritings() { - $this->collRewritings = null; // important to set this to null since that means it is uninitialized - $this->collRewritingsPartial = null; - - return $this; + $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collRewritings collection loaded partially - * - * @return void + * Reset is the collRewritings collection loaded partially. */ public function resetPartialRewritings($v = true) { @@ -2600,7 +2655,7 @@ abstract class BaseContent extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2610,25 +2665,25 @@ abstract class BaseContent extends BaseObject implements Persistent if (null !== $this->collRewritings && !$overrideExisting) { return; } - $this->collRewritings = new PropelObjectCollection(); - $this->collRewritings->setModel('Rewriting'); + $this->collRewritings = new ObjectCollection(); + $this->collRewritings->setModel('\Thelia\Model\Rewriting'); } /** - * Gets an array of Rewriting objects which contain a foreign key that references this object. + * Gets an array of ChildRewriting objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildContent is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildRewriting[] List of ChildRewriting objects * @throws PropelException */ - public function getRewritings($criteria = null, PropelPDO $con = null) + public function getRewritings($criteria = null, ConnectionInterface $con = null) { $partial = $this->collRewritingsPartial && !$this->isNew(); if (null === $this->collRewritings || null !== $criteria || $partial) { @@ -2636,29 +2691,31 @@ abstract class BaseContent extends BaseObject implements Persistent // return empty collection $this->initRewritings(); } else { - $collRewritings = RewritingQuery::create(null, $criteria) + $collRewritings = ChildRewritingQuery::create(null, $criteria) ->filterByContent($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); + $this->initRewritings(false); - foreach($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); + foreach ($collRewritings as $obj) { + if (false == $this->collRewritings->contains($obj)) { + $this->collRewritings->append($obj); + } } - } - $this->collRewritingsPartial = true; + $this->collRewritingsPartial = true; } $collRewritings->getInternalIterator()->rewind(); + return $collRewritings; } - if($partial && $this->collRewritings) { - foreach($this->collRewritings as $obj) { - if($obj->isNew()) { + if ($partial && $this->collRewritings) { + foreach ($this->collRewritings as $obj) { + if ($obj->isNew()) { $collRewritings[] = $obj; } } @@ -2678,15 +2735,16 @@ abstract class BaseContent extends BaseObject implements Persistent * It will 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) + * @param Collection $rewritings A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) */ - public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) + public function setRewritings(Collection $rewritings, ConnectionInterface $con = null) { $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); + + $this->rewritingsScheduledForDeletion = $rewritingsToDelete; foreach ($rewritingsToDelete as $rewritingRemoved) { $rewritingRemoved->setContent(null); @@ -2706,13 +2764,13 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Returns the number of related Rewriting objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Rewriting objects. * @throws PropelException */ - public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRewritingsPartial && !$this->isNew(); if (null === $this->collRewritings || null !== $criteria || $partial) { @@ -2720,10 +2778,11 @@ abstract class BaseContent extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getRewritings()); } - $query = RewritingQuery::create(null, $criteria); + + $query = ChildRewritingQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2737,18 +2796,19 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Method called to associate a Rewriting object to this object - * through the Rewriting foreign key attribute. + * Method called to associate a ChildRewriting object to this object + * through the ChildRewriting foreign key attribute. * - * @param Rewriting $l Rewriting - * @return Content The current object (for fluent API support) + * @param ChildRewriting $l ChildRewriting + * @return \Thelia\Model\Content The current object (for fluent API support) */ - public function addRewriting(Rewriting $l) + public function addRewriting(ChildRewriting $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); } @@ -2757,7 +2817,7 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param Rewriting $rewriting The rewriting object to add. + * @param Rewriting $rewriting The rewriting object to add. */ protected function doAddRewriting($rewriting) { @@ -2766,8 +2826,8 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return Content The current object (for fluent API support) + * @param Rewriting $rewriting The rewriting object to remove. + * @return ChildContent The current object (for fluent API support) */ public function removeRewriting($rewriting) { @@ -2796,15 +2856,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getRewritings($query, $con); } @@ -2821,15 +2881,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getRewritings($query, $con); } @@ -2846,15 +2906,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getRewritings($query, $con); } @@ -2865,21 +2925,16 @@ abstract class BaseContent extends BaseObject implements Persistent * This 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) + * @return void * @see addContentFolders() */ public function clearContentFolders() { - $this->collContentFolders = null; // important to set this to null since that means it is uninitialized - $this->collContentFoldersPartial = null; - - return $this; + $this->collContentFolders = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collContentFolders collection loaded partially - * - * @return void + * Reset is the collContentFolders collection loaded partially. */ public function resetPartialContentFolders($v = true) { @@ -2893,7 +2948,7 @@ abstract class BaseContent extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2903,25 +2958,25 @@ abstract class BaseContent extends BaseObject implements Persistent if (null !== $this->collContentFolders && !$overrideExisting) { return; } - $this->collContentFolders = new PropelObjectCollection(); - $this->collContentFolders->setModel('ContentFolder'); + $this->collContentFolders = new ObjectCollection(); + $this->collContentFolders->setModel('\Thelia\Model\ContentFolder'); } /** - * Gets an array of ContentFolder objects which contain a foreign key that references this object. + * Gets an array of ChildContentFolder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildContent is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentFolder[] List of ChildContentFolder objects * @throws PropelException */ - public function getContentFolders($criteria = null, PropelPDO $con = null) + public function getContentFolders($criteria = null, ConnectionInterface $con = null) { $partial = $this->collContentFoldersPartial && !$this->isNew(); if (null === $this->collContentFolders || null !== $criteria || $partial) { @@ -2929,29 +2984,31 @@ abstract class BaseContent extends BaseObject implements Persistent // return empty collection $this->initContentFolders(); } else { - $collContentFolders = ContentFolderQuery::create(null, $criteria) + $collContentFolders = ChildContentFolderQuery::create(null, $criteria) ->filterByContent($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collContentFoldersPartial && count($collContentFolders)) { - $this->initContentFolders(false); + $this->initContentFolders(false); - foreach($collContentFolders as $obj) { - if (false == $this->collContentFolders->contains($obj)) { - $this->collContentFolders->append($obj); + foreach ($collContentFolders as $obj) { + if (false == $this->collContentFolders->contains($obj)) { + $this->collContentFolders->append($obj); + } } - } - $this->collContentFoldersPartial = true; + $this->collContentFoldersPartial = true; } $collContentFolders->getInternalIterator()->rewind(); + return $collContentFolders; } - if($partial && $this->collContentFolders) { - foreach($this->collContentFolders as $obj) { - if($obj->isNew()) { + if ($partial && $this->collContentFolders) { + foreach ($this->collContentFolders as $obj) { + if ($obj->isNew()) { $collContentFolders[] = $obj; } } @@ -2971,15 +3028,19 @@ abstract class BaseContent extends BaseObject implements Persistent * It will 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) + * @param Collection $contentFolders A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) */ - public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) + public function setContentFolders(Collection $contentFolders, ConnectionInterface $con = null) { $contentFoldersToDelete = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); - $this->contentFoldersScheduledForDeletion = unserialize(serialize($contentFoldersToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->contentFoldersScheduledForDeletion = clone $contentFoldersToDelete; foreach ($contentFoldersToDelete as $contentFolderRemoved) { $contentFolderRemoved->setContent(null); @@ -2999,13 +3060,13 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Returns the number of related ContentFolder objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ContentFolder objects. * @throws PropelException */ - public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countContentFolders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collContentFoldersPartial && !$this->isNew(); if (null === $this->collContentFolders || null !== $criteria || $partial) { @@ -3013,10 +3074,11 @@ abstract class BaseContent extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getContentFolders()); } - $query = ContentFolderQuery::create(null, $criteria); + + $query = ChildContentFolderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3030,18 +3092,19 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Method called to associate a ContentFolder object to this object - * through the ContentFolder foreign key attribute. + * Method called to associate a ChildContentFolder object to this object + * through the ChildContentFolder foreign key attribute. * - * @param ContentFolder $l ContentFolder - * @return Content The current object (for fluent API support) + * @param ChildContentFolder $l ChildContentFolder + * @return \Thelia\Model\Content The current object (for fluent API support) */ - public function addContentFolder(ContentFolder $l) + public function addContentFolder(ChildContentFolder $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); } @@ -3050,7 +3113,7 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param ContentFolder $contentFolder The contentFolder object to add. + * @param ContentFolder $contentFolder The contentFolder object to add. */ protected function doAddContentFolder($contentFolder) { @@ -3059,8 +3122,8 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param ContentFolder $contentFolder The contentFolder object to remove. - * @return Content The current object (for fluent API support) + * @param ContentFolder $contentFolder The contentFolder object to remove. + * @return ChildContent The current object (for fluent API support) */ public function removeContentFolder($contentFolder) { @@ -3089,15 +3152,15 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildContentFolder[] List of ChildContentFolder objects */ - public function getContentFoldersJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getContentFoldersJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ContentFolderQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildContentFolderQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getContentFolders($query, $con); } @@ -3108,21 +3171,16 @@ abstract class BaseContent extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collContentI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collContentI18ns collection loaded partially - * - * @return void + * Reset is the collContentI18ns collection loaded partially. */ public function resetPartialContentI18ns($v = true) { @@ -3136,7 +3194,7 @@ abstract class BaseContent extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3146,25 +3204,25 @@ abstract class BaseContent extends BaseObject implements Persistent if (null !== $this->collContentI18ns && !$overrideExisting) { return; } - $this->collContentI18ns = new PropelObjectCollection(); - $this->collContentI18ns->setModel('ContentI18n'); + $this->collContentI18ns = new ObjectCollection(); + $this->collContentI18ns->setModel('\Thelia\Model\ContentI18n'); } /** - * Gets an array of ContentI18n objects which contain a foreign key that references this object. + * Gets an array of ChildContentI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildContent is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentI18n[] List of ChildContentI18n objects * @throws PropelException */ - public function getContentI18ns($criteria = null, PropelPDO $con = null) + public function getContentI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collContentI18nsPartial && !$this->isNew(); if (null === $this->collContentI18ns || null !== $criteria || $partial) { @@ -3172,29 +3230,31 @@ abstract class BaseContent extends BaseObject implements Persistent // return empty collection $this->initContentI18ns(); } else { - $collContentI18ns = ContentI18nQuery::create(null, $criteria) + $collContentI18ns = ChildContentI18nQuery::create(null, $criteria) ->filterByContent($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collContentI18nsPartial && count($collContentI18ns)) { - $this->initContentI18ns(false); + $this->initContentI18ns(false); - foreach($collContentI18ns as $obj) { - if (false == $this->collContentI18ns->contains($obj)) { - $this->collContentI18ns->append($obj); + foreach ($collContentI18ns as $obj) { + if (false == $this->collContentI18ns->contains($obj)) { + $this->collContentI18ns->append($obj); + } } - } - $this->collContentI18nsPartial = true; + $this->collContentI18nsPartial = true; } $collContentI18ns->getInternalIterator()->rewind(); + return $collContentI18ns; } - if($partial && $this->collContentI18ns) { - foreach($this->collContentI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collContentI18ns) { + foreach ($this->collContentI18ns as $obj) { + if ($obj->isNew()) { $collContentI18ns[] = $obj; } } @@ -3214,15 +3274,19 @@ abstract class BaseContent extends BaseObject implements Persistent * It will 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) + * @param Collection $contentI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) */ - public function setContentI18ns(PropelCollection $contentI18ns, PropelPDO $con = null) + public function setContentI18ns(Collection $contentI18ns, ConnectionInterface $con = null) { $contentI18nsToDelete = $this->getContentI18ns(new Criteria(), $con)->diff($contentI18ns); - $this->contentI18nsScheduledForDeletion = unserialize(serialize($contentI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->contentI18nsScheduledForDeletion = clone $contentI18nsToDelete; foreach ($contentI18nsToDelete as $contentI18nRemoved) { $contentI18nRemoved->setContent(null); @@ -3242,13 +3306,13 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Returns the number of related ContentI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ContentI18n objects. * @throws PropelException */ - public function countContentI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countContentI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collContentI18nsPartial && !$this->isNew(); if (null === $this->collContentI18ns || null !== $criteria || $partial) { @@ -3256,10 +3320,11 @@ abstract class BaseContent extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getContentI18ns()); } - $query = ContentI18nQuery::create(null, $criteria); + + $query = ChildContentI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3273,13 +3338,13 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Method called to associate a ContentI18n object to this object - * through the ContentI18n foreign key attribute. + * Method called to associate a ChildContentI18n object to this object + * through the ChildContentI18n foreign key attribute. * - * @param ContentI18n $l ContentI18n - * @return Content The current object (for fluent API support) + * @param ChildContentI18n $l ChildContentI18n + * @return \Thelia\Model\Content The current object (for fluent API support) */ - public function addContentI18n(ContentI18n $l) + public function addContentI18n(ChildContentI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -3289,6 +3354,7 @@ abstract class BaseContent extends BaseObject implements Persistent $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); } @@ -3297,7 +3363,7 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param ContentI18n $contentI18n The contentI18n object to add. + * @param ContentI18n $contentI18n The contentI18n object to add. */ protected function doAddContentI18n($contentI18n) { @@ -3306,8 +3372,8 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param ContentI18n $contentI18n The contentI18n object to remove. - * @return Content The current object (for fluent API support) + * @param ContentI18n $contentI18n The contentI18n object to remove. + * @return ChildContent The current object (for fluent API support) */ public function removeContentI18n($contentI18n) { @@ -3330,21 +3396,16 @@ abstract class BaseContent extends BaseObject implements Persistent * This 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) + * @return void * @see addContentVersions() */ public function clearContentVersions() { - $this->collContentVersions = null; // important to set this to null since that means it is uninitialized - $this->collContentVersionsPartial = null; - - return $this; + $this->collContentVersions = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collContentVersions collection loaded partially - * - * @return void + * Reset is the collContentVersions collection loaded partially. */ public function resetPartialContentVersions($v = true) { @@ -3358,7 +3419,7 @@ abstract class BaseContent extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3368,25 +3429,25 @@ abstract class BaseContent extends BaseObject implements Persistent if (null !== $this->collContentVersions && !$overrideExisting) { return; } - $this->collContentVersions = new PropelObjectCollection(); - $this->collContentVersions->setModel('ContentVersion'); + $this->collContentVersions = new ObjectCollection(); + $this->collContentVersions->setModel('\Thelia\Model\ContentVersion'); } /** - * Gets an array of ContentVersion objects which contain a foreign key that references this object. + * Gets an array of ChildContentVersion objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildContent is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentVersion[] List of ChildContentVersion objects * @throws PropelException */ - public function getContentVersions($criteria = null, PropelPDO $con = null) + public function getContentVersions($criteria = null, ConnectionInterface $con = null) { $partial = $this->collContentVersionsPartial && !$this->isNew(); if (null === $this->collContentVersions || null !== $criteria || $partial) { @@ -3394,29 +3455,31 @@ abstract class BaseContent extends BaseObject implements Persistent // return empty collection $this->initContentVersions(); } else { - $collContentVersions = ContentVersionQuery::create(null, $criteria) + $collContentVersions = ChildContentVersionQuery::create(null, $criteria) ->filterByContent($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collContentVersionsPartial && count($collContentVersions)) { - $this->initContentVersions(false); + $this->initContentVersions(false); - foreach($collContentVersions as $obj) { - if (false == $this->collContentVersions->contains($obj)) { - $this->collContentVersions->append($obj); + foreach ($collContentVersions as $obj) { + if (false == $this->collContentVersions->contains($obj)) { + $this->collContentVersions->append($obj); + } } - } - $this->collContentVersionsPartial = true; + $this->collContentVersionsPartial = true; } $collContentVersions->getInternalIterator()->rewind(); + return $collContentVersions; } - if($partial && $this->collContentVersions) { - foreach($this->collContentVersions as $obj) { - if($obj->isNew()) { + if ($partial && $this->collContentVersions) { + foreach ($this->collContentVersions as $obj) { + if ($obj->isNew()) { $collContentVersions[] = $obj; } } @@ -3436,15 +3499,19 @@ abstract class BaseContent extends BaseObject implements Persistent * It will 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) + * @param Collection $contentVersions A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) */ - public function setContentVersions(PropelCollection $contentVersions, PropelPDO $con = null) + public function setContentVersions(Collection $contentVersions, ConnectionInterface $con = null) { $contentVersionsToDelete = $this->getContentVersions(new Criteria(), $con)->diff($contentVersions); - $this->contentVersionsScheduledForDeletion = unserialize(serialize($contentVersionsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->contentVersionsScheduledForDeletion = clone $contentVersionsToDelete; foreach ($contentVersionsToDelete as $contentVersionRemoved) { $contentVersionRemoved->setContent(null); @@ -3464,13 +3531,13 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Returns the number of related ContentVersion objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ContentVersion objects. * @throws PropelException */ - public function countContentVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countContentVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collContentVersionsPartial && !$this->isNew(); if (null === $this->collContentVersions || null !== $criteria || $partial) { @@ -3478,10 +3545,11 @@ abstract class BaseContent extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getContentVersions()); } - $query = ContentVersionQuery::create(null, $criteria); + + $query = ChildContentVersionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3495,18 +3563,19 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Method called to associate a ContentVersion object to this object - * through the ContentVersion foreign key attribute. + * Method called to associate a ChildContentVersion object to this object + * through the ChildContentVersion foreign key attribute. * - * @param ContentVersion $l ContentVersion - * @return Content The current object (for fluent API support) + * @param ChildContentVersion $l ChildContentVersion + * @return \Thelia\Model\Content The current object (for fluent API support) */ - public function addContentVersion(ContentVersion $l) + public function addContentVersion(ChildContentVersion $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); } @@ -3515,7 +3584,7 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param ContentVersion $contentVersion The contentVersion object to add. + * @param ContentVersion $contentVersion The contentVersion object to add. */ protected function doAddContentVersion($contentVersion) { @@ -3524,8 +3593,8 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * @param ContentVersion $contentVersion The contentVersion object to remove. - * @return Content The current object (for fluent API support) + * @param ContentVersion $contentVersion The contentVersion object to remove. + * @return ChildContent The current object (for fluent API support) */ public function removeContentVersion($contentVersion) { @@ -3548,15 +3617,13 @@ abstract class BaseContent extends BaseObject implements Persistent * This 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) + * @return void * @see addFolders() */ public function clearFolders() { - $this->collFolders = null; // important to set this to null since that means it is uninitialized + $this->collFolders = null; // important to set this to NULL since that means it is uninitialized $this->collFoldersPartial = null; - - return $this; } /** @@ -3570,33 +3637,33 @@ abstract class BaseContent extends BaseObject implements Persistent */ public function initFolders() { - $this->collFolders = new PropelObjectCollection(); - $this->collFolders->setModel('Folder'); + $this->collFolders = new ObjectCollection(); + $this->collFolders->setModel('\Thelia\Model\Folder'); } /** - * Gets a collection of Folder objects related by a many-to-many relationship + * Gets a collection of ChildFolder 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 + * If this ChildContent 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Folder[] List of Folder objects + * @return ObjectCollection|ChildFolder[] List of ChildFolder objects */ - public function getFolders($criteria = null, PropelPDO $con = null) + public function getFolders($criteria = null, ConnectionInterface $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) + $collFolders = ChildFolderQuery::create(null, $criteria) ->filterByContent($this) ->find($con); if (null !== $criteria) { @@ -3615,11 +3682,11 @@ abstract class BaseContent extends BaseObject implements Persistent * It will 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) + * @param Collection $folders A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildContent The current object (for fluent API support) */ - public function setFolders(PropelCollection $folders, PropelPDO $con = null) + public function setFolders(Collection $folders, ConnectionInterface $con = null) { $this->clearFolders(); $currentFolders = $this->getFolders(); @@ -3638,22 +3705,22 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Gets the number of Folder objects related by a many-to-many relationship + * Gets the number of ChildFolder 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Folder objects + * @return int the number of related ChildFolder objects */ - public function countFolders($criteria = null, $distinct = false, PropelPDO $con = null) + public function countFolders($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collFolders || null !== $criteria) { if ($this->isNew() && null === $this->collFolders) { return 0; } else { - $query = FolderQuery::create(null, $criteria); + $query = ChildFolderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3668,52 +3735,60 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Associate a Folder object to this object + * Associate a ChildFolder 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) + * @param ChildFolder $folder The ChildContentFolder object to relate + * @return ChildContent The current object (for fluent API support) */ - public function addFolder(Folder $folder) + public function addFolder(ChildFolder $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; + $this->collFolders[] = $folder; } return $this; } /** - * @param Folder $folder The folder object to add. + * @param Folder $folder The folder object to add. */ protected function doAddFolder($folder) { - $contentFolder = new ContentFolder(); + $contentFolder = new ChildContentFolder(); $contentFolder->setFolder($folder); $this->addContentFolder($contentFolder); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$folder->getContents()->contains($this)) { + $foreignCollection = $folder->getContents(); + $foreignCollection[] = $this; + } } /** - * Remove a Folder object to this object + * Remove a ChildFolder 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) + * @param ChildFolder $folder The ChildContentFolder object to relate + * @return ChildContent The current object (for fluent API support) */ - public function removeFolder(Folder $folder) + public function removeFolder(ChildFolder $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; + + $this->foldersScheduledForDeletion[] = $folder; } return $this; @@ -3733,8 +3808,6 @@ abstract class BaseContent extends BaseObject implements Persistent $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(); @@ -3747,14 +3820,13 @@ abstract class BaseContent extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collContentAssocs) { foreach ($this->collContentAssocs as $o) { $o->clearAllReferences($deep); @@ -3795,66 +3867,54 @@ abstract class BaseContent extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collContentAssocs instanceof PropelCollection) { + if ($this->collContentAssocs instanceof Collection) { $this->collContentAssocs->clearIterator(); } $this->collContentAssocs = null; - if ($this->collImages instanceof PropelCollection) { + if ($this->collImages instanceof Collection) { $this->collImages->clearIterator(); } $this->collImages = null; - if ($this->collDocuments instanceof PropelCollection) { + if ($this->collDocuments instanceof Collection) { $this->collDocuments->clearIterator(); } $this->collDocuments = null; - if ($this->collRewritings instanceof PropelCollection) { + if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } $this->collRewritings = null; - if ($this->collContentFolders instanceof PropelCollection) { + if ($this->collContentFolders instanceof Collection) { $this->collContentFolders->clearIterator(); } $this->collContentFolders = null; - if ($this->collContentI18ns instanceof PropelCollection) { + if ($this->collContentI18ns instanceof Collection) { $this->collContentI18ns->clearIterator(); } $this->collContentI18ns = null; - if ($this->collContentVersions instanceof PropelCollection) { + if ($this->collContentVersions instanceof Collection) { $this->collContentVersions->clearIterator(); } $this->collContentVersions = null; - if ($this->collFolders instanceof PropelCollection) { + if ($this->collFolders instanceof Collection) { $this->collFolders->clearIterator(); } $this->collFolders = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(ContentTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -3862,11 +3922,11 @@ abstract class BaseContent extends BaseObject implements Persistent /** * 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) + * @return ChildContent The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = ContentPeer::UPDATED_AT; + $this->modifiedColumns[] = ContentTableMap::UPDATED_AT; return $this; } @@ -3878,9 +3938,9 @@ abstract class BaseContent extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Content The current object (for fluent API support) + * @return ChildContent The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -3901,10 +3961,10 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return ContentI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildContentI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collContentI18ns) { @@ -3917,10 +3977,10 @@ abstract class BaseContent extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new ContentI18n(); + $translation = new ChildContentI18n(); $translation->setLocale($locale); } else { - $translation = ContentI18nQuery::create() + $translation = ChildContentI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -3935,14 +3995,14 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Content The current object (for fluent API support) + * @return ChildContent The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - ContentI18nQuery::create() + ChildContentI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -3962,10 +4022,10 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return ContentI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildContentI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -3974,7 +4034,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -3985,8 +4045,8 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -3998,7 +4058,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -4009,8 +4069,8 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -4022,7 +4082,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -4033,8 +4093,8 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -4046,7 +4106,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -4057,8 +4117,8 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -4071,7 +4131,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Enforce a new Version of this object upon next save. * - * @return Content + * @return \Thelia\Model\Content */ public function enforceVersioning() { @@ -4083,8 +4143,6 @@ abstract class BaseContent extends BaseObject implements Persistent /** * 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) @@ -4097,7 +4155,7 @@ abstract class BaseContent extends BaseObject implements Persistent return true; } - if (ContentPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) { + if (ChildContentQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) { return true; } @@ -4107,15 +4165,15 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Creates a version of the current object and saves it. * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return ContentVersion A version object + * @return ChildContentVersion A version object */ public function addVersion($con = null) { $this->enforceVersion = false; - $version = new ContentVersion(); + $version = new ChildContentVersion(); $version->setId($this->getId()); $version->setVisible($this->getVisible()); $version->setPosition($this->getPosition()); @@ -4131,19 +4189,18 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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 + * @param ConnectionInterface $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. + * @return ChildContent The current object (for fluent API support) */ 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)); + throw new PropelException(sprintf('No ChildContent object found with version %d', $version)); } $this->populateFromVersion($version, $con); @@ -4151,18 +4208,17 @@ abstract class BaseContent extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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. + * @param ChildContentVersion $version The version object to use + * @param ConnectionInterface $con the connection to use + * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects. * - * @return Content The current object (for fluent API support) + * @return ChildContent The current object (for fluent API support) */ public function populateFromVersion($version, $con = null, &$loadedObjects = array()) { - - $loadedObjects['Content'][$version->getId()][$version->getVersion()] = $this; + $loadedObjects['ChildContent'][$version->getId()][$version->getVersion()] = $this; $this->setId($version->getId()); $this->setVisible($version->getVisible()); $this->setPosition($version->getPosition()); @@ -4178,13 +4234,13 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Gets the latest persisted version number for the current object * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * * @return integer */ public function getLastVersionNumber($con = null) { - $v = ContentVersionQuery::create() + $v = ChildContentVersionQuery::create() ->filterByContent($this) ->orderByVersion('desc') ->findOne($con); @@ -4198,9 +4254,9 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Checks whether the current object is the latest one * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return boolean + * @return Boolean */ public function isLastVersion($con = null) { @@ -4211,13 +4267,13 @@ abstract class BaseContent extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con the connection to use * - * @return ContentVersion A version object + * @return ChildContentVersion A version object */ public function getOneVersion($versionNumber, $con = null) { - return ContentVersionQuery::create() + return ChildContentVersionQuery::create() ->filterByContent($this) ->filterByVersion($versionNumber) ->findOne($con); @@ -4226,14 +4282,14 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Gets all the versions of this object, in incremental order * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return PropelObjectCollection A list of ContentVersion objects + * @return ObjectCollection A list of ChildContentVersion objects */ public function getAllVersions($con = null) { $criteria = new Criteria(); - $criteria->addAscendingOrderByColumn(ContentVersionPeer::VERSION); + $criteria->addAscendingOrderByColumn(ContentVersionTableMap::VERSION); return $this->getContentVersions($criteria, $con); } @@ -4248,10 +4304,10 @@ abstract class BaseContent extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $versionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -4273,11 +4329,11 @@ abstract class BaseContent extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $fromVersionNumber + * @param integer $toVersionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -4292,7 +4348,7 @@ abstract class BaseContent extends BaseObject implements Persistent /** * Computes the diff between two versions. * - * print_r($this->computeDiff(1, 2)); + * print_r($book->computeDiff(1, 2)); * => array( * '1' => array('Title' => 'Book title at version 1'), * '2' => array('Title' => 'Book title at version 2') @@ -4341,18 +4397,133 @@ abstract class BaseContent extends BaseObject implements Persistent /** * 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 + * @param Integer $number the number of record to return. + * @return PropelCollection|array \Thelia\Model\ContentVersion[] List of \Thelia\Model\ContentVersion objects */ - public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null) + public function getLastVersions($number = 10, $criteria = null, $con = null) { - $criteria = ContentVersionQuery::create(null, $criteria); - $criteria->addDescendingOrderByColumn(ContentVersionPeer::VERSION); + $criteria = ChildContentVersionQuery::create(null, $criteria); + $criteria->addDescendingOrderByColumn(ContentVersionTableMap::VERSION); $criteria->limit($number); return $this->getContentVersions($criteria, $con); } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/ContentAssoc.php b/core/lib/Thelia/Model/Base/ContentAssoc.php new file mode 100644 index 000000000..eaa1cb9b7 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentAssoc.php @@ -0,0 +1,1688 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ContentAssoc instance. If + * obj is an instance of ContentAssoc, delegates to + * equals(ContentAssoc). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ContentAssoc The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ContentAssoc The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ContentAssocTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [category_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) + */ + public function setCategoryId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->category_id !== $v) { + $this->category_id = $v; + $this->modifiedColumns[] = ContentAssocTableMap::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 \Thelia\Model\ContentAssoc The current object (for fluent API support) + */ + public function setProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->product_id !== $v) { + $this->product_id = $v; + $this->modifiedColumns[] = ContentAssocTableMap::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 \Thelia\Model\ContentAssoc The current object (for fluent API support) + */ + public function setContentId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->content_id !== $v) { + $this->content_id = $v; + $this->modifiedColumns[] = ContentAssocTableMap::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 \Thelia\Model\ContentAssoc The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = ContentAssocTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ContentAssocTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ContentAssocTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentAssocTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentAssocTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentAssocTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentAssocTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentAssocTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentAssocTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ContentAssocTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = ContentAssocTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ContentAssoc object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ContentAssocTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildContentAssocQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see ContentAssoc::setDeleted() + * @see ContentAssoc::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildContentAssocQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ContentAssocTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ContentAssocTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = ContentAssocTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentAssocTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ContentAssocTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ContentAssocTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; + } + if ($this->isColumnModified(ContentAssocTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; + } + if ($this->isColumnModified(ContentAssocTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; + } + if ($this->isColumnModified(ContentAssocTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(ContentAssocTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ContentAssocTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentAssocTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()] = true; + $keys = ContentAssocTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentAssocTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ContentAssocTableMap::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(ContentAssocTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ContentAssocTableMap::ID)) $criteria->add(ContentAssocTableMap::ID, $this->id); + if ($this->isColumnModified(ContentAssocTableMap::CATEGORY_ID)) $criteria->add(ContentAssocTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(ContentAssocTableMap::PRODUCT_ID)) $criteria->add(ContentAssocTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(ContentAssocTableMap::CONTENT_ID)) $criteria->add(ContentAssocTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(ContentAssocTableMap::POSITION)) $criteria->add(ContentAssocTableMap::POSITION, $this->position); + if ($this->isColumnModified(ContentAssocTableMap::CREATED_AT)) $criteria->add(ContentAssocTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ContentAssocTableMap::UPDATED_AT)) $criteria->add(ContentAssocTableMap::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(ContentAssocTableMap::DATABASE_NAME); + $criteria->add(ContentAssocTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $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 ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addContentAssoc($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::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 ChildProduct object. + * + * @param ChildProduct $v + * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) + * @throws PropelException + */ + public function setProduct(ChildProduct $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 ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addContentAssoc($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProduct(ConnectionInterface $con = null) + { + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::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 ChildContent object. + * + * @param ChildContent $v + * @return \Thelia\Model\ContentAssoc The current object (for fluent API support) + * @throws PropelException + */ + public function setContent(ChildContent $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 ChildContent object, it will not be re-added. + if ($v !== null) { + $v->addContentAssoc($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCategory = null; + $this->aProduct = null; + $this->aContent = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ContentAssocTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildContentAssoc The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ContentAssocTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php b/core/lib/Thelia/Model/Base/ContentAssocQuery.php old mode 100755 new mode 100644 similarity index 54% rename from core/lib/Thelia/Model/om/BaseContentAssocQuery.php rename to core/lib/Thelia/Model/Base/ContentAssocQuery.php index 709046cf2..630af8065 --- a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php +++ b/core/lib/Thelia/Model/Base/ContentAssocQuery.php @@ -1,109 +1,107 @@ setModelAlias($modelAlias); } @@ -124,21 +122,21 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return ContentAssoc|ContentAssoc[]|mixed the result, formatted by the current formatter + * @return ChildContentAssoc|array|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 + if ((null !== ($obj = ContentAssocTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ContentAssocTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -150,46 +148,31 @@ abstract class BaseContentAssocQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return ContentAssoc A model object, or null if the key is not found - * @throws PropelException + * @return ChildContentAssoc A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ContentAssoc(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildContentAssoc(); $obj->hydrate($row); - ContentAssocPeer::addInstanceToPool($obj, (string) $key); + ContentAssocTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -200,19 +183,19 @@ abstract class BaseContentAssocQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ContentAssoc|ContentAssoc[]|mixed the result, formatted by the current formatter + * @return ChildContentAssoc|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -221,22 +204,22 @@ abstract class BaseContentAssocQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ContentAssoc[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -244,12 +227,12 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ContentAssocQuery The current query, for fluid interface + * @return ChildContentAssocQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(ContentAssocPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(ContentAssocTableMap::ID, $key, Criteria::EQUAL); } /** @@ -257,12 +240,12 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ContentAssocQuery The current query, for fluid interface + * @return ChildContentAssocQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(ContentAssocPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(ContentAssocTableMap::ID, $keys, Criteria::IN); } /** @@ -272,8 +255,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -282,18 +264,18 @@ abstract class BaseContentAssocQuery extends ModelCriteria * 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 + * @return ChildContentAssocQuery 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); + $this->addUsingAlias(ContentAssocTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ContentAssocPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentAssocTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -304,7 +286,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentAssocPeer::ID, $id, $comparison); + return $this->addUsingAlias(ContentAssocTableMap::ID, $id, $comparison); } /** @@ -314,8 +296,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $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 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 * * * @see filterByCategory() @@ -326,18 +307,18 @@ abstract class BaseContentAssocQuery extends ModelCriteria * 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 + * @return ChildContentAssocQuery 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); + $this->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($categoryId['max'])) { - $this->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -348,7 +329,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $categoryId, $comparison); } /** @@ -358,8 +339,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $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 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 * * * @see filterByProduct() @@ -370,18 +350,18 @@ abstract class BaseContentAssocQuery extends ModelCriteria * 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 + * @return ChildContentAssocQuery 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); + $this->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($productId['max'])) { - $this->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -392,7 +372,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $productId, $comparison); + return $this->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $productId, $comparison); } /** @@ -402,8 +382,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $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 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 * * * @see filterByContent() @@ -414,18 +393,18 @@ abstract class BaseContentAssocQuery extends ModelCriteria * 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 + * @return ChildContentAssocQuery 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); + $this->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($contentId['max'])) { - $this->addUsingAlias(ContentAssocPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -436,7 +415,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentAssocPeer::CONTENT_ID, $contentId, $comparison); + return $this->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $contentId, $comparison); } /** @@ -446,8 +425,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -456,18 +434,18 @@ abstract class BaseContentAssocQuery extends ModelCriteria * 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 + * @return ChildContentAssocQuery 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); + $this->addUsingAlias(ContentAssocTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(ContentAssocPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentAssocTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -478,7 +456,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentAssocPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(ContentAssocTableMap::POSITION, $position, $comparison); } /** @@ -499,18 +477,18 @@ abstract class BaseContentAssocQuery extends ModelCriteria * 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 + * @return ChildContentAssocQuery 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); + $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ContentAssocPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -521,7 +499,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentAssocPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -542,18 +520,18 @@ abstract class BaseContentAssocQuery extends ModelCriteria * 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 + * @return ChildContentAssocQuery 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); + $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -564,32 +542,31 @@ abstract class BaseContentAssocQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Category object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Category|ObjectCollection $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. + * @return ChildContentAssocQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = null) { - if ($category instanceof Category) { + if ($category instanceof \Thelia\Model\Category) { return $this - ->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { + ->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ContentAssocTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); } } @@ -599,7 +576,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria * @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 + * @return ChildContentAssocQuery The current query, for fluid interface */ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -628,7 +605,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria /** * Use the Category relation Category object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -644,28 +621,27 @@ abstract class BaseContentAssocQuery extends ModelCriteria } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildContentAssocQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ContentAssocTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -675,7 +651,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria * @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 + * @return ChildContentAssocQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -704,7 +680,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -720,28 +696,27 @@ abstract class BaseContentAssocQuery extends ModelCriteria } /** - * Filter the query by a related Content object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Content|ObjectCollection $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. + * @return ChildContentAssocQuery The current query, for fluid interface */ public function filterByContent($content, $comparison = null) { - if ($content instanceof Content) { + if ($content instanceof \Thelia\Model\Content) { return $this - ->addUsingAlias(ContentAssocPeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { + ->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ContentAssocPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ContentAssocTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); } } @@ -751,7 +726,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria * @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 + * @return ChildContentAssocQuery The current query, for fluid interface */ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -780,7 +755,7 @@ abstract class BaseContentAssocQuery extends ModelCriteria /** * Use the Content relation Content object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -798,19 +773,94 @@ abstract class BaseContentAssocQuery extends ModelCriteria /** * Exclude object from result * - * @param ContentAssoc $contentAssoc Object to remove from the list of results + * @param ChildContentAssoc $contentAssoc Object to remove from the list of results * - * @return ContentAssocQuery The current query, for fluid interface + * @return ChildContentAssocQuery The current query, for fluid interface */ public function prune($contentAssoc = null) { if ($contentAssoc) { - $this->addUsingAlias(ContentAssocPeer::ID, $contentAssoc->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(ContentAssocTableMap::ID, $contentAssoc->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the content_assoc table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ContentAssocTableMap::clearInstancePool(); + ContentAssocTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildContentAssoc or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildContentAssoc object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ContentAssocTableMap::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(); + + + ContentAssocTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ContentAssocTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -818,31 +868,11 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ContentAssocQuery The current query, for fluid interface + * @return ChildContentAssocQuery 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); + return $this->addUsingAlias(ContentAssocTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -850,30 +880,51 @@ abstract class BaseContentAssocQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ContentAssocQuery The current query, for fluid interface + * @return ChildContentAssocQuery 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); + return $this->addUsingAlias(ContentAssocTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildContentAssocQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ContentAssocTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildContentAssocQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ContentAssocTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ContentAssocQuery The current query, for fluid interface + * @return ChildContentAssocQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(ContentAssocPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(ContentAssocTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ContentAssocQuery The current query, for fluid interface + * @return ChildContentAssocQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(ContentAssocPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(ContentAssocTableMap::CREATED_AT); } -} + +} // ContentAssocQuery diff --git a/core/lib/Thelia/Model/Base/ContentFolder.php b/core/lib/Thelia/Model/Base/ContentFolder.php new file mode 100644 index 000000000..52f5fa88a --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentFolder.php @@ -0,0 +1,1433 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ContentFolder instance. If + * obj is an instance of ContentFolder, delegates to + * equals(ContentFolder). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ContentFolder The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ContentFolder The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [content_id] column value. + * + * @return int + */ + public function getContentId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [content_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentFolder The current object (for fluent API support) + */ + public function setContentId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->content_id !== $v) { + $this->content_id = $v; + $this->modifiedColumns[] = ContentFolderTableMap::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 \Thelia\Model\ContentFolder The current object (for fluent API support) + */ + public function setFolderId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->folder_id !== $v) { + $this->folder_id = $v; + $this->modifiedColumns[] = ContentFolderTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ContentFolderTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ContentFolderTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentFolderTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentFolderTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->folder_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentFolderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentFolderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = ContentFolderTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ContentFolder object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ContentFolderTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildContentFolderQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see ContentFolder::setDeleted() + * @see ContentFolder::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildContentFolderQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ContentFolderTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ContentFolderTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ContentFolderTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ContentFolderTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ContentFolderTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; + } + if ($this->isColumnModified(ContentFolderTableMap::FOLDER_ID)) { + $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; + } + if ($this->isColumnModified(ContentFolderTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ContentFolderTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentFolderTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ContentFolder'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ContentFolder'][serialize($this->getPrimaryKey())] = true; + $keys = ContentFolderTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getContentId(), + $keys[1] => $this->getFolderId(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentFolderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ContentFolderTableMap::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(ContentFolderTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ContentFolderTableMap::CONTENT_ID)) $criteria->add(ContentFolderTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(ContentFolderTableMap::FOLDER_ID)) $criteria->add(ContentFolderTableMap::FOLDER_ID, $this->folder_id); + if ($this->isColumnModified(ContentFolderTableMap::CREATED_AT)) $criteria->add(ContentFolderTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ContentFolderTableMap::UPDATED_AT)) $criteria->add(ContentFolderTableMap::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(ContentFolderTableMap::DATABASE_NAME); + $criteria->add(ContentFolderTableMap::CONTENT_ID, $this->content_id); + $criteria->add(ContentFolderTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildContent object. + * + * @param ChildContent $v + * @return \Thelia\Model\ContentFolder The current object (for fluent API support) + * @throws PropelException + */ + public function setContent(ChildContent $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 ChildContent object, it will not be re-added. + if ($v !== null) { + $v->addContentFolder($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::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 ChildFolder object. + * + * @param ChildFolder $v + * @return \Thelia\Model\ContentFolder The current object (for fluent API support) + * @throws PropelException + */ + public function setFolder(ChildFolder $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 ChildFolder object, it will not be re-added. + if ($v !== null) { + $v->addContentFolder($this); + } + + + return $this; + } + + + /** + * Get the associated ChildFolder object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFolder The associated ChildFolder object. + * @throws PropelException + */ + public function getFolder(ConnectionInterface $con = null) + { + if ($this->aFolder === null && ($this->folder_id !== null)) { + $this->aFolder = ChildFolderQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aContent = null; + $this->aFolder = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ContentFolderTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildContentFolder The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ContentFolderTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php b/core/lib/Thelia/Model/Base/ContentFolderQuery.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseContentFolderQuery.php rename to core/lib/Thelia/Model/Base/ContentFolderQuery.php index 0a44bc555..208ba80cf --- a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php +++ b/core/lib/Thelia/Model/Base/ContentFolderQuery.php @@ -1,93 +1,91 @@ setModelAlias($modelAlias); } @@ -107,23 +105,22 @@ abstract class BaseContentFolderQuery extends ModelCriteria * $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 + * @param array[$content_id, $folder_id] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ContentFolder|ContentFolder[]|mixed the result, formatted by the current formatter + * @return ChildContentFolder|array|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 + if ((null !== ($obj = ContentFolderTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ContentFolderTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -140,14 +137,13 @@ abstract class BaseContentFolderQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ContentFolder A model object, or null if the key is not found - * @throws PropelException + * @return ChildContentFolder A model object, or null if the key is not found */ 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'; + $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); @@ -155,13 +151,13 @@ abstract class BaseContentFolderQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ContentFolder(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildContentFolder(); $obj->hydrate($row); - ContentFolderPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ContentFolderTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -172,19 +168,19 @@ abstract class BaseContentFolderQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ContentFolder|ContentFolder[]|mixed the result, formatted by the current formatter + * @return ChildContentFolder|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -193,22 +189,22 @@ abstract class BaseContentFolderQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ContentFolder[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -216,12 +212,12 @@ abstract class BaseContentFolderQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ContentFolderQuery The current query, for fluid interface + * @return ChildContentFolderQuery 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); + $this->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $key[1], Criteria::EQUAL); return $this; } @@ -231,7 +227,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ContentFolderQuery The current query, for fluid interface + * @return ChildContentFolderQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -239,8 +235,8 @@ abstract class BaseContentFolderQuery extends ModelCriteria 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 = $this->getNewCriterion(ContentFolderTableMap::CONTENT_ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ContentFolderTableMap::FOLDER_ID, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -255,8 +251,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria * * $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 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 * * * @see filterByContent() @@ -267,18 +262,18 @@ abstract class BaseContentFolderQuery extends ModelCriteria * 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 + * @return ChildContentFolderQuery 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); + $this->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($contentId['max'])) { - $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -289,7 +284,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $contentId, $comparison); + return $this->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $contentId, $comparison); } /** @@ -299,8 +294,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria * * $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 + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 * * * @see filterByFolder() @@ -311,18 +305,18 @@ abstract class BaseContentFolderQuery extends ModelCriteria * 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 + * @return ChildContentFolderQuery 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); + $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($folderId['max'])) { - $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -333,7 +327,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId, $comparison); + return $this->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folderId, $comparison); } /** @@ -354,18 +348,18 @@ abstract class BaseContentFolderQuery extends ModelCriteria * 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 + * @return ChildContentFolderQuery 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); + $this->addUsingAlias(ContentFolderTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ContentFolderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentFolderTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -376,7 +370,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentFolderPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ContentFolderTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -397,18 +391,18 @@ abstract class BaseContentFolderQuery extends ModelCriteria * 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 + * @return ChildContentFolderQuery 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); + $this->addUsingAlias(ContentFolderTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentFolderTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -419,32 +413,31 @@ abstract class BaseContentFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ContentFolderTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Content object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Content|ObjectCollection $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. + * @return ChildContentFolderQuery The current query, for fluid interface */ public function filterByContent($content, $comparison = null) { - if ($content instanceof Content) { + if ($content instanceof \Thelia\Model\Content) { return $this - ->addUsingAlias(ContentFolderPeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { + ->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ContentFolderPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ContentFolderTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); } } @@ -454,7 +447,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria * @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 + * @return ChildContentFolderQuery The current query, for fluid interface */ public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -483,7 +476,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria /** * Use the Content relation Content object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -499,28 +492,27 @@ abstract class BaseContentFolderQuery extends ModelCriteria } /** - * Filter the query by a related Folder object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Folder|ObjectCollection $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. + * @return ChildContentFolderQuery The current query, for fluid interface */ public function filterByFolder($folder, $comparison = null) { - if ($folder instanceof Folder) { + if ($folder instanceof \Thelia\Model\Folder) { return $this - ->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { + ->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folder->getId(), $comparison); + } elseif ($folder instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ContentFolderTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); + throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); } } @@ -530,7 +522,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria * @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 + * @return ChildContentFolderQuery The current query, for fluid interface */ public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -559,7 +551,7 @@ abstract class BaseContentFolderQuery extends ModelCriteria /** * Use the Folder relation Folder object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -577,21 +569,96 @@ abstract class BaseContentFolderQuery extends ModelCriteria /** * Exclude object from result * - * @param ContentFolder $contentFolder Object to remove from the list of results + * @param ChildContentFolder $contentFolder Object to remove from the list of results * - * @return ContentFolderQuery The current query, for fluid interface + * @return ChildContentFolderQuery 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->addCond('pruneCond0', $this->getAliasedColName(ContentFolderTableMap::CONTENT_ID), $contentFolder->getContentId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ContentFolderTableMap::FOLDER_ID), $contentFolder->getFolderId(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } + /** + * Deletes all rows from the content_folder table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ContentFolderTableMap::clearInstancePool(); + ContentFolderTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildContentFolder or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildContentFolder object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ContentFolderTableMap::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(); + + + ContentFolderTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ContentFolderTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -599,31 +666,11 @@ abstract class BaseContentFolderQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ContentFolderQuery The current query, for fluid interface + * @return ChildContentFolderQuery 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); + return $this->addUsingAlias(ContentFolderTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -631,30 +678,51 @@ abstract class BaseContentFolderQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ContentFolderQuery The current query, for fluid interface + * @return ChildContentFolderQuery 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); + return $this->addUsingAlias(ContentFolderTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildContentFolderQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ContentFolderTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildContentFolderQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ContentFolderTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ContentFolderQuery The current query, for fluid interface + * @return ChildContentFolderQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(ContentFolderPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(ContentFolderTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ContentFolderQuery The current query, for fluid interface + * @return ChildContentFolderQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(ContentFolderPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(ContentFolderTableMap::CREATED_AT); } -} + +} // ContentFolderQuery diff --git a/core/lib/Thelia/Model/Base/ContentI18n.php b/core/lib/Thelia/Model/Base/ContentI18n.php new file mode 100644 index 000000000..14ff02b39 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ContentI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ContentI18n instance. If + * obj is an instance of ContentI18n, delegates to + * equals(ContentI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ContentI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ContentI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ContentI18nTableMap::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 \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ContentI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ContentI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ContentI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ContentI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ContentI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ContentI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ContentI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ContentI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildContentI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aContent = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ContentI18n::setDeleted() + * @see ContentI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildContentI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME); + } + + $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); + ContentI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ContentI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ContentI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ContentI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ContentI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ContentI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ContentI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ContentI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ContentI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ContentI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ContentI18nTableMap::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(ContentI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ContentI18nTableMap::ID)) $criteria->add(ContentI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ContentI18nTableMap::LOCALE)) $criteria->add(ContentI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ContentI18nTableMap::TITLE)) $criteria->add(ContentI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ContentI18nTableMap::DESCRIPTION)) $criteria->add(ContentI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ContentI18nTableMap::CHAPO)) $criteria->add(ContentI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ContentI18nTableMap::POSTSCRIPTUM)) $criteria->add(ContentI18nTableMap::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(ContentI18nTableMap::DATABASE_NAME); + $criteria->add(ContentI18nTableMap::ID, $this->id); + $criteria->add(ContentI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildContent object. + * + * @param ChildContent $v + * @return \Thelia\Model\ContentI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setContent(ChildContent $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 ChildContent object, it will not be re-added. + if ($v !== null) { + $v->addContentI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->id !== null)) { + $this->aContent = ChildContentQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aContent = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ContentI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseContentI18nQuery.php b/core/lib/Thelia/Model/Base/ContentI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseContentI18nQuery.php rename to core/lib/Thelia/Model/Base/ContentI18nQuery.php index 44aa8dab2..cfd638318 --- a/core/lib/Thelia/Model/om/BaseContentI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ContentI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseContentI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ContentI18n|ContentI18n[]|mixed the result, formatted by the current formatter + * @return ChildContentI18n|array|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 + if ((null !== ($obj = ContentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ContentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ContentI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseContentI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ContentI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildContentI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `content_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseContentI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ContentI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildContentI18n(); $obj->hydrate($row); - ContentI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ContentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseContentI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ContentI18n|ContentI18n[]|mixed the result, formatted by the current formatter + * @return ChildContentI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseContentI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ContentI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseContentI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ContentI18nQuery The current query, for fluid interface + * @return ChildContentI18nQuery 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); + $this->addUsingAlias(ContentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ContentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ContentI18nQuery The current query, for fluid interface + * @return ChildContentI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseContentI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(ContentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ContentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByContent() @@ -270,18 +266,18 @@ abstract class BaseContentI18nQuery extends ModelCriteria * 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 + * @return ChildContentI18nQuery 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); + $this->addUsingAlias(ContentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ContentI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(ContentI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria * 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 + * @return ChildContentI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(ContentI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria * 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 + * @return ChildContentI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(ContentI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria * 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 + * @return ChildContentI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(ContentI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria * 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 + * @return ChildContentI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(ContentI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria * 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 + * @return ChildContentI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseContentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(ContentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Content object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Content|ObjectCollection $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. + * @return ChildContentI18nQuery The current query, for fluid interface */ public function filterByContent($content, $comparison = null) { - if ($content instanceof Content) { + if ($content instanceof \Thelia\Model\Content) { return $this - ->addUsingAlias(ContentI18nPeer::ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { + ->addUsingAlias(ContentI18nTableMap::ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ContentI18nPeer::ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ContentI18nTableMap::ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria * @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 + * @return ChildContentI18nQuery The current query, for fluid interface */ public function joinContent($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseContentI18nQuery extends ModelCriteria /** * Use the Content relation Content object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseContentI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param ContentI18n $contentI18n Object to remove from the list of results + * @param ChildContentI18n $contentI18n Object to remove from the list of results * - * @return ContentI18nQuery The current query, for fluid interface + * @return ChildContentI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(ContentI18nTableMap::ID), $contentI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ContentI18nTableMap::LOCALE), $contentI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the content_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ContentI18nTableMap::clearInstancePool(); + ContentI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildContentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildContentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ContentI18nTableMap::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(); + + + ContentI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ContentI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ContentI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php old mode 100755 new mode 100644 similarity index 59% rename from core/lib/Thelia/Model/om/BaseContentQuery.php rename to core/lib/Thelia/Model/Base/ContentQuery.php index 5cb162d1a..2c4b9da04 --- a/core/lib/Thelia/Model/om/BaseContentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentQuery.php @@ -1,134 +1,135 @@ setModelAlias($modelAlias); } @@ -149,21 +150,21 @@ abstract class BaseContentQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Content|Content[]|mixed the result, formatted by the current formatter + * @return ChildContent|array|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 + if ((null !== ($obj = ContentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ContentTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -175,46 +176,31 @@ abstract class BaseContentQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Content A model object, or null if the key is not found - * @throws PropelException + * @return ChildContent A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Content(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildContent(); $obj->hydrate($row); - ContentPeer::addInstanceToPool($obj, (string) $key); + ContentTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -225,19 +211,19 @@ abstract class BaseContentQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Content|Content[]|mixed the result, formatted by the current formatter + * @return ChildContent|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -246,22 +232,22 @@ abstract class BaseContentQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Content[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -269,12 +255,12 @@ abstract class BaseContentQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ContentQuery The current query, for fluid interface + * @return ChildContentQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(ContentPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(ContentTableMap::ID, $key, Criteria::EQUAL); } /** @@ -282,12 +268,12 @@ abstract class BaseContentQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ContentQuery The current query, for fluid interface + * @return ChildContentQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(ContentPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(ContentTableMap::ID, $keys, Criteria::IN); } /** @@ -297,8 +283,7 @@ abstract class BaseContentQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -307,18 +292,18 @@ abstract class BaseContentQuery extends ModelCriteria * 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 + * @return ChildContentQuery 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); + $this->addUsingAlias(ContentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ContentPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -329,7 +314,7 @@ abstract class BaseContentQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentPeer::ID, $id, $comparison); + return $this->addUsingAlias(ContentTableMap::ID, $id, $comparison); } /** @@ -339,8 +324,7 @@ abstract class BaseContentQuery extends ModelCriteria * * $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 + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 * * * @param mixed $visible The value to use as filter. @@ -349,18 +333,18 @@ abstract class BaseContentQuery extends ModelCriteria * 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 + * @return ChildContentQuery 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); + $this->addUsingAlias(ContentTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($visible['max'])) { - $this->addUsingAlias(ContentPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -371,7 +355,7 @@ abstract class BaseContentQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentPeer::VISIBLE, $visible, $comparison); + return $this->addUsingAlias(ContentTableMap::VISIBLE, $visible, $comparison); } /** @@ -381,8 +365,7 @@ abstract class BaseContentQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -391,18 +374,18 @@ abstract class BaseContentQuery extends ModelCriteria * 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 + * @return ChildContentQuery 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); + $this->addUsingAlias(ContentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(ContentPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -413,7 +396,7 @@ abstract class BaseContentQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(ContentTableMap::POSITION, $position, $comparison); } /** @@ -434,18 +417,18 @@ abstract class BaseContentQuery extends ModelCriteria * 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 + * @return ChildContentQuery 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); + $this->addUsingAlias(ContentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ContentPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -456,7 +439,7 @@ abstract class BaseContentQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ContentTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -477,18 +460,18 @@ abstract class BaseContentQuery extends ModelCriteria * 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 + * @return ChildContentQuery 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); + $this->addUsingAlias(ContentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -499,7 +482,7 @@ abstract class BaseContentQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ContentTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -509,8 +492,7 @@ abstract class BaseContentQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -519,18 +501,18 @@ abstract class BaseContentQuery extends ModelCriteria * 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 + * @return ChildContentQuery 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); + $this->addUsingAlias(ContentTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(ContentPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -541,7 +523,7 @@ abstract class BaseContentQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentPeer::VERSION, $version, $comparison); + return $this->addUsingAlias(ContentTableMap::VERSION, $version, $comparison); } /** @@ -562,18 +544,18 @@ abstract class BaseContentQuery extends ModelCriteria * 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 + * @return ChildContentQuery 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); + $this->addUsingAlias(ContentTableMap::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); + $this->addUsingAlias(ContentTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -584,7 +566,7 @@ abstract class BaseContentQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(ContentTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -600,7 +582,7 @@ abstract class BaseContentQuery extends ModelCriteria * 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 + * @return ChildContentQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -613,30 +595,29 @@ abstract class BaseContentQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(ContentTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related ContentAssoc object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ContentAssoc|ObjectCollection $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. + * @return ChildContentQuery The current query, for fluid interface */ public function filterByContentAssoc($contentAssoc, $comparison = null) { - if ($contentAssoc instanceof ContentAssoc) { + if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) { return $this - ->addUsingAlias(ContentPeer::ID, $contentAssoc->getContentId(), $comparison); - } elseif ($contentAssoc instanceof PropelObjectCollection) { + ->addUsingAlias(ContentTableMap::ID, $contentAssoc->getContentId(), $comparison); + } elseif ($contentAssoc instanceof ObjectCollection) { return $this ->useContentAssocQuery() ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); + throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection'); } } @@ -646,7 +627,7 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentQuery The current query, for fluid interface */ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -675,7 +656,7 @@ abstract class BaseContentQuery extends ModelCriteria /** * Use the ContentAssoc relation ContentAssoc object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -691,26 +672,25 @@ abstract class BaseContentQuery extends ModelCriteria } /** - * Filter the query by a related Image object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Image|ObjectCollection $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. + * @return ChildContentQuery The current query, for fluid interface */ public function filterByImage($image, $comparison = null) { - if ($image instanceof Image) { + if ($image instanceof \Thelia\Model\Image) { return $this - ->addUsingAlias(ContentPeer::ID, $image->getContentId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { + ->addUsingAlias(ContentTableMap::ID, $image->getContentId(), $comparison); + } elseif ($image instanceof ObjectCollection) { return $this ->useImageQuery() ->filterByPrimaryKeys($image->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); + throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); } } @@ -720,7 +700,7 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentQuery The current query, for fluid interface */ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -749,7 +729,7 @@ abstract class BaseContentQuery extends ModelCriteria /** * Use the Image relation Image object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -765,26 +745,25 @@ abstract class BaseContentQuery extends ModelCriteria } /** - * Filter the query by a related Document object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Document|ObjectCollection $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. + * @return ChildContentQuery The current query, for fluid interface */ public function filterByDocument($document, $comparison = null) { - if ($document instanceof Document) { + if ($document instanceof \Thelia\Model\Document) { return $this - ->addUsingAlias(ContentPeer::ID, $document->getContentId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { + ->addUsingAlias(ContentTableMap::ID, $document->getContentId(), $comparison); + } elseif ($document instanceof ObjectCollection) { return $this ->useDocumentQuery() ->filterByPrimaryKeys($document->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); + throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); } } @@ -794,7 +773,7 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentQuery The current query, for fluid interface */ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -823,7 +802,7 @@ abstract class BaseContentQuery extends ModelCriteria /** * Use the Document relation Document object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -839,26 +818,25 @@ abstract class BaseContentQuery extends ModelCriteria } /** - * Filter the query by a related Rewriting object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Rewriting|ObjectCollection $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. + * @return ChildContentQuery The current query, for fluid interface */ public function filterByRewriting($rewriting, $comparison = null) { - if ($rewriting instanceof Rewriting) { + if ($rewriting instanceof \Thelia\Model\Rewriting) { return $this - ->addUsingAlias(ContentPeer::ID, $rewriting->getContentId(), $comparison); - } elseif ($rewriting instanceof PropelObjectCollection) { + ->addUsingAlias(ContentTableMap::ID, $rewriting->getContentId(), $comparison); + } elseif ($rewriting instanceof ObjectCollection) { return $this ->useRewritingQuery() ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection'); + throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection'); } } @@ -868,7 +846,7 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentQuery The current query, for fluid interface */ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -897,7 +875,7 @@ abstract class BaseContentQuery extends ModelCriteria /** * Use the Rewriting relation Rewriting object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -913,26 +891,25 @@ abstract class BaseContentQuery extends ModelCriteria } /** - * Filter the query by a related ContentFolder object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ContentFolder|ObjectCollection $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. + * @return ChildContentQuery The current query, for fluid interface */ public function filterByContentFolder($contentFolder, $comparison = null) { - if ($contentFolder instanceof ContentFolder) { + if ($contentFolder instanceof \Thelia\Model\ContentFolder) { return $this - ->addUsingAlias(ContentPeer::ID, $contentFolder->getContentId(), $comparison); - } elseif ($contentFolder instanceof PropelObjectCollection) { + ->addUsingAlias(ContentTableMap::ID, $contentFolder->getContentId(), $comparison); + } elseif ($contentFolder instanceof ObjectCollection) { return $this ->useContentFolderQuery() ->filterByPrimaryKeys($contentFolder->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection'); + throw new PropelException('filterByContentFolder() only accepts arguments of type \Thelia\Model\ContentFolder or Collection'); } } @@ -942,7 +919,7 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentQuery The current query, for fluid interface */ public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -971,7 +948,7 @@ abstract class BaseContentQuery extends ModelCriteria /** * Use the ContentFolder relation ContentFolder object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -987,26 +964,25 @@ abstract class BaseContentQuery extends ModelCriteria } /** - * Filter the query by a related ContentI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ContentI18n|ObjectCollection $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. + * @return ChildContentQuery The current query, for fluid interface */ public function filterByContentI18n($contentI18n, $comparison = null) { - if ($contentI18n instanceof ContentI18n) { + if ($contentI18n instanceof \Thelia\Model\ContentI18n) { return $this - ->addUsingAlias(ContentPeer::ID, $contentI18n->getId(), $comparison); - } elseif ($contentI18n instanceof PropelObjectCollection) { + ->addUsingAlias(ContentTableMap::ID, $contentI18n->getId(), $comparison); + } elseif ($contentI18n instanceof ObjectCollection) { return $this ->useContentI18nQuery() ->filterByPrimaryKeys($contentI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByContentI18n() only accepts arguments of type ContentI18n or PropelCollection'); + throw new PropelException('filterByContentI18n() only accepts arguments of type \Thelia\Model\ContentI18n or Collection'); } } @@ -1016,7 +992,7 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentQuery The current query, for fluid interface */ public function joinContentI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -1045,7 +1021,7 @@ abstract class BaseContentQuery extends ModelCriteria /** * Use the ContentI18n relation ContentI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1061,26 +1037,25 @@ abstract class BaseContentQuery extends ModelCriteria } /** - * Filter the query by a related ContentVersion object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ContentVersion|ObjectCollection $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. + * @return ChildContentQuery The current query, for fluid interface */ public function filterByContentVersion($contentVersion, $comparison = null) { - if ($contentVersion instanceof ContentVersion) { + if ($contentVersion instanceof \Thelia\Model\ContentVersion) { return $this - ->addUsingAlias(ContentPeer::ID, $contentVersion->getId(), $comparison); - } elseif ($contentVersion instanceof PropelObjectCollection) { + ->addUsingAlias(ContentTableMap::ID, $contentVersion->getId(), $comparison); + } elseif ($contentVersion instanceof ObjectCollection) { return $this ->useContentVersionQuery() ->filterByPrimaryKeys($contentVersion->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByContentVersion() only accepts arguments of type ContentVersion or PropelCollection'); + throw new PropelException('filterByContentVersion() only accepts arguments of type \Thelia\Model\ContentVersion or Collection'); } } @@ -1090,7 +1065,7 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentQuery The current query, for fluid interface */ public function joinContentVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1119,7 +1094,7 @@ abstract class BaseContentQuery extends ModelCriteria /** * Use the ContentVersion relation ContentVersion object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1138,10 +1113,10 @@ abstract class BaseContentQuery extends ModelCriteria * 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 + * @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 + * @return ChildContentQuery The current query, for fluid interface */ public function filterByFolder($folder, $comparison = Criteria::EQUAL) { @@ -1154,19 +1129,94 @@ abstract class BaseContentQuery extends ModelCriteria /** * Exclude object from result * - * @param Content $content Object to remove from the list of results + * @param ChildContent $content Object to remove from the list of results * - * @return ContentQuery The current query, for fluid interface + * @return ChildContentQuery The current query, for fluid interface */ public function prune($content = null) { if ($content) { - $this->addUsingAlias(ContentPeer::ID, $content->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(ContentTableMap::ID, $content->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ContentTableMap::clearInstancePool(); + ContentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildContent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildContent object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ContentTableMap::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(); + + + ContentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ContentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -1174,31 +1224,11 @@ abstract class BaseContentQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ContentQuery The current query, for fluid interface + * @return ChildContentQuery 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); + return $this->addUsingAlias(ContentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -1206,32 +1236,53 @@ abstract class BaseContentQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ContentQuery The current query, for fluid interface + * @return ChildContentQuery 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); + return $this->addUsingAlias(ContentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ContentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildContentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ContentTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ContentQuery The current query, for fluid interface + * @return ChildContentQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(ContentPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(ContentTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ContentQuery The current query, for fluid interface + * @return ChildContentQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(ContentPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(ContentTableMap::CREATED_AT); } + // i18n behavior /** @@ -1241,9 +1292,9 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ContentI18n'; @@ -1259,9 +1310,9 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1280,13 +1331,41 @@ abstract class BaseContentQuery extends ModelCriteria * @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 + * @return ChildContentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentI18n', 'Thelia\Model\ContentI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'ContentI18n', '\Thelia\Model\ContentI18nQuery'); } -} + // versionable behavior + + /** + * Checks whether versioning is enabled + * + * @return boolean + */ + static public function isVersioningEnabled() + { + return self::$isVersioningEnabled; + } + + /** + * Enables versioning + */ + static public function enableVersioning() + { + self::$isVersioningEnabled = true; + } + + /** + * Disables versioning + */ + static public function disableVersioning() + { + self::$isVersioningEnabled = false; + } + +} // ContentQuery diff --git a/core/lib/Thelia/Model/Base/ContentVersion.php b/core/lib/Thelia/Model/Base/ContentVersion.php new file mode 100644 index 000000000..ca9189608 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ContentVersion.php @@ -0,0 +1,1593 @@ +version = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\ContentVersion object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ContentVersion instance. If + * obj is an instance of ContentVersion, delegates to + * equals(ContentVersion). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ContentVersion The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ContentVersion The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + } + } + + /** + * 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 \Thelia\Model\ContentVersion The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ContentVersionTableMap::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 \Thelia\Model\ContentVersion The current object (for fluent API support) + */ + public function setVisible($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->visible !== $v) { + $this->visible = $v; + $this->modifiedColumns[] = ContentVersionTableMap::VISIBLE; + } + + + return $this; + } // setVisible() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentVersion The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = ContentVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ContentVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ContentVersionTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Set the value of [version] column. + * + * @param int $v new value + * @return \Thelia\Model\ContentVersion The current object (for fluent API support) + */ + public function setVersion($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->version !== $v) { + $this->version = $v; + $this->modifiedColumns[] = ContentVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = ContentVersionTableMap::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 \Thelia\Model\ContentVersion The current object (for fluent API support) + */ + public function setVersionCreatedBy($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->version_created_by !== $v) { + $this->version_created_by = $v; + $this->modifiedColumns[] = ContentVersionTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ContentVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ContentVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ContentVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ContentVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ContentVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ContentVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ContentVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ContentVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 8; // 8 = ContentVersionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ContentVersion object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ContentVersionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildContentVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aContent = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ContentVersion::setDeleted() + * @see ContentVersion::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildContentVersionQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME); + } + + $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); + ContentVersionTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ContentVersionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ContentVersionTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; + } + if ($this->isColumnModified(ContentVersionTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(ContentVersionTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ContentVersionTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + if ($this->isColumnModified(ContentVersionTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; + } + if ($this->isColumnModified(ContentVersionTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; + } + if ($this->isColumnModified(ContentVersionTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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 ? $this->version_created_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentVersionTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ContentVersion'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ContentVersion'][serialize($this->getPrimaryKey())] = true; + $keys = ContentVersionTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ContentVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ContentVersionTableMap::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(ContentVersionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ContentVersionTableMap::ID)) $criteria->add(ContentVersionTableMap::ID, $this->id); + if ($this->isColumnModified(ContentVersionTableMap::VISIBLE)) $criteria->add(ContentVersionTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(ContentVersionTableMap::POSITION)) $criteria->add(ContentVersionTableMap::POSITION, $this->position); + if ($this->isColumnModified(ContentVersionTableMap::CREATED_AT)) $criteria->add(ContentVersionTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ContentVersionTableMap::UPDATED_AT)) $criteria->add(ContentVersionTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(ContentVersionTableMap::VERSION)) $criteria->add(ContentVersionTableMap::VERSION, $this->version); + if ($this->isColumnModified(ContentVersionTableMap::VERSION_CREATED_AT)) $criteria->add(ContentVersionTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(ContentVersionTableMap::VERSION_CREATED_BY)) $criteria->add(ContentVersionTableMap::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(ContentVersionTableMap::DATABASE_NAME); + $criteria->add(ContentVersionTableMap::ID, $this->id); + $criteria->add(ContentVersionTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildContent object. + * + * @param ChildContent $v + * @return \Thelia\Model\ContentVersion The current object (for fluent API support) + * @throws PropelException + */ + public function setContent(ChildContent $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 ChildContent object, it will not be re-added. + if ($v !== null) { + $v->addContentVersion($this); + } + + + return $this; + } + + + /** + * Get the associated ChildContent object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. + * @throws PropelException + */ + public function getContent(ConnectionInterface $con = null) + { + if ($this->aContent === null && ($this->id !== null)) { + $this->aContent = ChildContentQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aContent = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ContentVersionTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseContentVersionQuery.php b/core/lib/Thelia/Model/Base/ContentVersionQuery.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseContentVersionQuery.php rename to core/lib/Thelia/Model/Base/ContentVersionQuery.php index 576a3ac02..ae737d96e --- a/core/lib/Thelia/Model/om/BaseContentVersionQuery.php +++ b/core/lib/Thelia/Model/Base/ContentVersionQuery.php @@ -1,104 +1,103 @@ setModelAlias($modelAlias); } @@ -118,23 +117,22 @@ abstract class BaseContentVersionQuery extends ModelCriteria * $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 + * @param array[$id, $version] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ContentVersion|ContentVersion[]|mixed the result, formatted by the current formatter + * @return ChildContentVersion|array|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 + if ((null !== ($obj = ContentVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ContentVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ContentVersionTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -151,14 +149,13 @@ abstract class BaseContentVersionQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ContentVersion A model object, or null if the key is not found - * @throws PropelException + * @return ChildContentVersion A model object, or null if the key is not found */ 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'; + $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); @@ -166,13 +163,13 @@ abstract class BaseContentVersionQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ContentVersion(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildContentVersion(); $obj->hydrate($row); - ContentVersionPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ContentVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -183,19 +180,19 @@ abstract class BaseContentVersionQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ContentVersion|ContentVersion[]|mixed the result, formatted by the current formatter + * @return ChildContentVersion|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -204,22 +201,22 @@ abstract class BaseContentVersionQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ContentVersion[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -227,12 +224,12 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ContentVersionQuery The current query, for fluid interface + * @return ChildContentVersionQuery 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); + $this->addUsingAlias(ContentVersionTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ContentVersionTableMap::VERSION, $key[1], Criteria::EQUAL); return $this; } @@ -242,7 +239,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ContentVersionQuery The current query, for fluid interface + * @return ChildContentVersionQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -250,8 +247,8 @@ abstract class BaseContentVersionQuery extends ModelCriteria 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 = $this->getNewCriterion(ContentVersionTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ContentVersionTableMap::VERSION, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -266,8 +263,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByContent() @@ -278,18 +274,18 @@ abstract class BaseContentVersionQuery extends ModelCriteria * 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 + * @return ChildContentVersionQuery 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); + $this->addUsingAlias(ContentVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ContentVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -300,7 +296,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentVersionPeer::ID, $id, $comparison); + return $this->addUsingAlias(ContentVersionTableMap::ID, $id, $comparison); } /** @@ -310,8 +306,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * $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 + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 * * * @param mixed $visible The value to use as filter. @@ -320,18 +315,18 @@ abstract class BaseContentVersionQuery extends ModelCriteria * 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 + * @return ChildContentVersionQuery 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); + $this->addUsingAlias(ContentVersionTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($visible['max'])) { - $this->addUsingAlias(ContentVersionPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentVersionTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -342,7 +337,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentVersionPeer::VISIBLE, $visible, $comparison); + return $this->addUsingAlias(ContentVersionTableMap::VISIBLE, $visible, $comparison); } /** @@ -352,8 +347,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -362,18 +356,18 @@ abstract class BaseContentVersionQuery extends ModelCriteria * 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 + * @return ChildContentVersionQuery 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); + $this->addUsingAlias(ContentVersionTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(ContentVersionPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentVersionTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -384,7 +378,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentVersionPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(ContentVersionTableMap::POSITION, $position, $comparison); } /** @@ -405,18 +399,18 @@ abstract class BaseContentVersionQuery extends ModelCriteria * 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 + * @return ChildContentVersionQuery 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); + $this->addUsingAlias(ContentVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ContentVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -427,7 +421,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentVersionPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ContentVersionTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -448,18 +442,18 @@ abstract class BaseContentVersionQuery extends ModelCriteria * 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 + * @return ChildContentVersionQuery 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); + $this->addUsingAlias(ContentVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ContentVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -470,7 +464,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentVersionPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ContentVersionTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -480,8 +474,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -490,18 +483,18 @@ abstract class BaseContentVersionQuery extends ModelCriteria * 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 + * @return ChildContentVersionQuery 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); + $this->addUsingAlias(ContentVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(ContentVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ContentVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -512,7 +505,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentVersionPeer::VERSION, $version, $comparison); + return $this->addUsingAlias(ContentVersionTableMap::VERSION, $version, $comparison); } /** @@ -533,18 +526,18 @@ abstract class BaseContentVersionQuery extends ModelCriteria * 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 + * @return ChildContentVersionQuery 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); + $this->addUsingAlias(ContentVersionTableMap::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); + $this->addUsingAlias(ContentVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -555,7 +548,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(ContentVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -571,7 +564,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria * 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 + * @return ChildContentVersionQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -584,32 +577,31 @@ abstract class BaseContentVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ContentVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(ContentVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related Content object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Content|ObjectCollection $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. + * @return ChildContentVersionQuery The current query, for fluid interface */ public function filterByContent($content, $comparison = null) { - if ($content instanceof Content) { + if ($content instanceof \Thelia\Model\Content) { return $this - ->addUsingAlias(ContentVersionPeer::ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { + ->addUsingAlias(ContentVersionTableMap::ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ContentVersionPeer::ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ContentVersionTableMap::ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); } } @@ -619,7 +611,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria * @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 + * @return ChildContentVersionQuery The current query, for fluid interface */ public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -648,7 +640,7 @@ abstract class BaseContentVersionQuery extends ModelCriteria /** * Use the Content relation Content object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -666,19 +658,94 @@ abstract class BaseContentVersionQuery extends ModelCriteria /** * Exclude object from result * - * @param ContentVersion $contentVersion Object to remove from the list of results + * @param ChildContentVersion $contentVersion Object to remove from the list of results * - * @return ContentVersionQuery The current query, for fluid interface + * @return ChildContentVersionQuery 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->addCond('pruneCond0', $this->getAliasedColName(ContentVersionTableMap::ID), $contentVersion->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ContentVersionTableMap::VERSION), $contentVersion->getVersion(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the content_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ContentVersionTableMap::clearInstancePool(); + ContentVersionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildContentVersion or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildContentVersion object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ContentVersionTableMap::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(); + + + ContentVersionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ContentVersionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ContentVersionQuery diff --git a/core/lib/Thelia/Model/om/BaseCountry.php b/core/lib/Thelia/Model/Base/Country.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseCountry.php rename to core/lib/Thelia/Model/Base/Country.php index 964ccac65..c59c3585e --- a/core/lib/Thelia/Model/om/BaseCountry.php +++ b/core/lib/Thelia/Model/Base/Country.php @@ -1,57 +1,65 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Country instance. If + * obj is an instance of Country, delegates to + * equals(Country). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Country The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Country The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [area_id] column value. * - * @return int + * @return int */ public function getAreaId() { + return $this->area_id; } /** * Get the [isocode] column value. * - * @return string + * @return string */ public function getIsocode() { + return $this->isocode; } /** * Get the [isoalpha2] column value. * - * @return string + * @return string */ public function getIsoalpha2() { + return $this->isoalpha2; } /** * Get the [isoalpha3] column value. * - * @return string + * @return string */ public function getIsoalpha3() { + return $this->isoalpha3; } @@ -212,97 +467,57 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Country The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = CountryPeer::ID; + $this->modifiedColumns[] = CountryTableMap::ID; } @@ -312,18 +527,18 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Set the value of [area_id] column. * - * @param int $v new value - * @return Country The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Country The current object (for fluent API support) */ public function setAreaId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->area_id !== $v) { $this->area_id = $v; - $this->modifiedColumns[] = CountryPeer::AREA_ID; + $this->modifiedColumns[] = CountryTableMap::AREA_ID; } if ($this->aArea !== null && $this->aArea->getId() !== $v) { @@ -337,18 +552,18 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Set the value of [isocode] column. * - * @param string $v new value - * @return Country The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Country The current object (for fluent API support) */ public function setIsocode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->isocode !== $v) { $this->isocode = $v; - $this->modifiedColumns[] = CountryPeer::ISOCODE; + $this->modifiedColumns[] = CountryTableMap::ISOCODE; } @@ -358,18 +573,18 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Set the value of [isoalpha2] column. * - * @param string $v new value - * @return Country The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Country The current object (for fluent API support) */ public function setIsoalpha2($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->isoalpha2 !== $v) { $this->isoalpha2 = $v; - $this->modifiedColumns[] = CountryPeer::ISOALPHA2; + $this->modifiedColumns[] = CountryTableMap::ISOALPHA2; } @@ -379,18 +594,18 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Set the value of [isoalpha3] column. * - * @param string $v new value - * @return Country The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Country The current object (for fluent API support) */ public function setIsoalpha3($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->isoalpha3 !== $v) { $this->isoalpha3 = $v; - $this->modifiedColumns[] = CountryPeer::ISOALPHA3; + $this->modifiedColumns[] = CountryTableMap::ISOALPHA3; } @@ -400,19 +615,17 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Country The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CountryTableMap::CREATED_AT; } } // if either are not null @@ -423,19 +636,17 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Country The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CountryTableMap::UPDATED_AT; } } // if either are not null @@ -453,7 +664,7 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -465,23 +676,47 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CountryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CountryTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->area_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CountryTableMap::translateFieldName('Isocode', TableMap::TYPE_PHPNAME, $indexType)]; + $this->isocode = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CountryTableMap::translateFieldName('Isoalpha2', TableMap::TYPE_PHPNAME, $indexType)]; + $this->isoalpha2 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CountryTableMap::translateFieldName('Isoalpha3', TableMap::TYPE_PHPNAME, $indexType)]; + $this->isoalpha3 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -489,11 +724,11 @@ abstract class BaseCountry extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = CountryPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 7; // 7 = CountryTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Country object", $e); + throw new PropelException("Error populating \Thelia\Model\Country object", 0, $e); } } @@ -512,7 +747,6 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) { $this->aArea = null; } @@ -523,12 +757,12 @@ abstract class BaseCountry extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -539,24 +773,24 @@ abstract class BaseCountry extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CountryTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildCountryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? $this->aArea = null; - $this->collTaxRuleCountrys = null; + $this->collTaxRuleCountries = null; $this->collCountryI18ns = null; @@ -566,26 +800,25 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Country::setDeleted() + * @see Country::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = CountryQuery::create() + $deleteQuery = ChildCountryQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -610,20 +843,19 @@ abstract class BaseCountry extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -633,16 +865,16 @@ abstract class BaseCountry extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(CountryPeer::CREATED_AT)) { + if (!$this->isColumnModified(CountryTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(CountryPeer::UPDATED_AT)) { + if (!$this->isColumnModified(CountryTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CountryPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(CountryTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -654,7 +886,7 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - CountryPeer::addInstanceToPool($this); + CountryTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -673,19 +905,19 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -707,18 +939,17 @@ abstract class BaseCountry extends BaseObject implements Persistent $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->taxRuleCountriesScheduledForDeletion !== null) { + if (!$this->taxRuleCountriesScheduledForDeletion->isEmpty()) { + \Thelia\Model\TaxRuleCountryQuery::create() + ->filterByPrimaryKeys($this->taxRuleCountriesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->taxRuleCountriesScheduledForDeletion = null; } } - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { + if ($this->collTaxRuleCountries !== null) { + foreach ($this->collTaxRuleCountries as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -727,15 +958,15 @@ abstract class BaseCountry extends BaseObject implements Persistent if ($this->countryI18nsScheduledForDeletion !== null) { if (!$this->countryI18nsScheduledForDeletion->isEmpty()) { - CountryI18nQuery::create() + \Thelia\Model\CountryI18nQuery::create() ->filterByPrimaryKeys($this->countryI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->countryI18nsScheduledForDeletion = null; } } - if ($this->collCountryI18ns !== null) { - foreach ($this->collCountryI18ns as $referrerFK) { + if ($this->collCountryI18ns !== null) { + foreach ($this->collCountryI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -752,42 +983,42 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $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(CountryTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(CountryPeer::AREA_ID)) { - $modifiedColumns[':p' . $index++] = '`area_id`'; + if ($this->isColumnModified(CountryTableMap::AREA_ID)) { + $modifiedColumns[':p' . $index++] = 'AREA_ID'; } - if ($this->isColumnModified(CountryPeer::ISOCODE)) { - $modifiedColumns[':p' . $index++] = '`isocode`'; + if ($this->isColumnModified(CountryTableMap::ISOCODE)) { + $modifiedColumns[':p' . $index++] = 'ISOCODE'; } - if ($this->isColumnModified(CountryPeer::ISOALPHA2)) { - $modifiedColumns[':p' . $index++] = '`isoalpha2`'; + if ($this->isColumnModified(CountryTableMap::ISOALPHA2)) { + $modifiedColumns[':p' . $index++] = 'ISOALPHA2'; } - if ($this->isColumnModified(CountryPeer::ISOALPHA3)) { - $modifiedColumns[':p' . $index++] = '`isoalpha3`'; + if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) { + $modifiedColumns[':p' . $index++] = 'ISOALPHA3'; } - if ($this->isColumnModified(CountryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(CountryTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(CountryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(CountryTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `country` (%s) VALUES (%s)', + 'INSERT INTO country (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -796,33 +1027,33 @@ abstract class BaseCountry extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`area_id`': + case 'AREA_ID': $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); break; - case '`isocode`': + case 'ISOCODE': $stmt->bindValue($identifier, $this->isocode, PDO::PARAM_STR); break; - case '`isoalpha2`': + case 'ISOALPHA2': $stmt->bindValue($identifier, $this->isoalpha2, PDO::PARAM_STR); break; - case '`isoalpha3`': + case 'ISOALPHA3': $stmt->bindValue($identifier, $this->isoalpha3, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } $this->setNew(false); @@ -831,132 +1062,32 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = CountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CountryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -966,7 +1097,7 @@ abstract class BaseCountry extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1005,22 +1136,22 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = CountryTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getAreaId(), @@ -1030,12 +1161,18 @@ abstract class BaseCountry extends BaseObject implements Persistent $keys[5] => $this->getCreatedAt(), $keys[6] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + 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->collTaxRuleCountries) { + $result['TaxRuleCountries'] = $this->collTaxRuleCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collCountryI18ns) { $result['CountryI18ns'] = $this->collCountryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1048,27 +1185,27 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = CountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CountryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1107,17 +1244,17 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = CountryPeer::getFieldNames($keyType); + $keys = CountryTableMap::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]]); @@ -1135,15 +1272,15 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(CountryPeer::DATABASE_NAME); + $criteria = new Criteria(CountryTableMap::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); + if ($this->isColumnModified(CountryTableMap::ID)) $criteria->add(CountryTableMap::ID, $this->id); + if ($this->isColumnModified(CountryTableMap::AREA_ID)) $criteria->add(CountryTableMap::AREA_ID, $this->area_id); + if ($this->isColumnModified(CountryTableMap::ISOCODE)) $criteria->add(CountryTableMap::ISOCODE, $this->isocode); + if ($this->isColumnModified(CountryTableMap::ISOALPHA2)) $criteria->add(CountryTableMap::ISOALPHA2, $this->isoalpha2); + if ($this->isColumnModified(CountryTableMap::ISOALPHA3)) $criteria->add(CountryTableMap::ISOALPHA3, $this->isoalpha3); + if ($this->isColumnModified(CountryTableMap::CREATED_AT)) $criteria->add(CountryTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CountryTableMap::UPDATED_AT)) $criteria->add(CountryTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1158,15 +1295,15 @@ abstract class BaseCountry extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(CountryPeer::DATABASE_NAME); - $criteria->add(CountryPeer::ID, $this->id); + $criteria = new Criteria(CountryTableMap::DATABASE_NAME); + $criteria->add(CountryTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1176,7 +1313,7 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1200,13 +1337,14 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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->setId($this->getId()); $copyObj->setAreaId($this->getAreaId()); $copyObj->setIsocode($this->getIsocode()); $copyObj->setIsoalpha2($this->getIsoalpha2()); @@ -1214,14 +1352,12 @@ abstract class BaseCountry extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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) { + foreach ($this->getTaxRuleCountries() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addTaxRuleCountry($relObj->copy($deepCopy)); } @@ -1233,13 +1369,10 @@ abstract class BaseCountry extends BaseObject implements Persistent } } - //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 } } @@ -1251,8 +1384,8 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Country Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1266,31 +1399,13 @@ abstract class BaseCountry extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildArea object. * - * 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) + * @param ChildArea $v + * @return \Thelia\Model\Country The current object (for fluent API support) * @throws PropelException */ - public function setArea(Area $v = null) + public function setArea(ChildArea $v = null) { if ($v === null) { $this->setAreaId(NULL); @@ -1301,7 +1416,7 @@ abstract class BaseCountry extends BaseObject implements Persistent $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 this object has already been added to the ChildArea object, it will not be re-added. if ($v !== null) { $v->addCountry($this); } @@ -1312,23 +1427,22 @@ abstract class BaseCountry extends BaseObject implements Persistent /** - * Get the associated Area object + * Get the associated ChildArea object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Area The associated Area object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildArea The associated ChildArea object. * @throws PropelException */ - public function getArea(PropelPDO $con = null, $doQuery = true) + public function getArea(ConnectionInterface $con = null) { - if ($this->aArea === null && ($this->area_id !== null) && $doQuery) { - $this->aArea = AreaQuery::create()->findPk($this->area_id, $con); + if ($this->aArea === null && ($this->area_id !== null)) { + $this->aArea = ChildAreaQuery::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); + $this->aArea->addCountries($this); */ } @@ -1341,123 +1455,120 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('TaxRuleCountry' == $relationName) { - $this->initTaxRuleCountrys(); + return $this->initTaxRuleCountries(); } if ('CountryI18n' == $relationName) { - $this->initCountryI18ns(); + return $this->initCountryI18ns(); } } /** - * Clears out the collTaxRuleCountrys collection + * Clears out the collTaxRuleCountries collection * * This 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 + * @see addTaxRuleCountries() */ - public function resetPartialTaxRuleCountrys($v = true) + public function clearTaxRuleCountries() { - $this->collTaxRuleCountrysPartial = $v; + $this->collTaxRuleCountries = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collTaxRuleCountrys collection. + * Reset is the collTaxRuleCountries collection loaded partially. + */ + public function resetPartialTaxRuleCountries($v = true) + { + $this->collTaxRuleCountriesPartial = $v; + } + + /** + * Initializes the collTaxRuleCountries collection. * - * By default this just sets the collTaxRuleCountrys collection to an empty array (like clearcollTaxRuleCountrys()); + * By default this just sets the collTaxRuleCountries collection to an empty array (like clearcollTaxRuleCountries()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initTaxRuleCountries($overrideExisting = true) { - if (null !== $this->collTaxRuleCountrys && !$overrideExisting) { + if (null !== $this->collTaxRuleCountries && !$overrideExisting) { return; } - $this->collTaxRuleCountrys = new PropelObjectCollection(); - $this->collTaxRuleCountrys->setModel('TaxRuleCountry'); + $this->collTaxRuleCountries = new ObjectCollection(); + $this->collTaxRuleCountries->setModel('\Thelia\Model\TaxRuleCountry'); } /** - * Gets an array of TaxRuleCountry objects which contain a foreign key that references this object. + * Gets an array of ChildTaxRuleCountry objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCountry is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects * @throws PropelException */ - public function getTaxRuleCountrys($criteria = null, PropelPDO $con = null) + public function getTaxRuleCountries($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { + $partial = $this->collTaxRuleCountriesPartial && !$this->isNew(); + if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTaxRuleCountries) { // return empty collection - $this->initTaxRuleCountrys(); + $this->initTaxRuleCountries(); } else { - $collTaxRuleCountrys = TaxRuleCountryQuery::create(null, $criteria) + $collTaxRuleCountries = ChildTaxRuleCountryQuery::create(null, $criteria) ->filterByCountry($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collTaxRuleCountrysPartial && count($collTaxRuleCountrys)) { - $this->initTaxRuleCountrys(false); + if (false !== $this->collTaxRuleCountriesPartial && count($collTaxRuleCountries)) { + $this->initTaxRuleCountries(false); - foreach($collTaxRuleCountrys as $obj) { - if (false == $this->collTaxRuleCountrys->contains($obj)) { - $this->collTaxRuleCountrys->append($obj); + foreach ($collTaxRuleCountries as $obj) { + if (false == $this->collTaxRuleCountries->contains($obj)) { + $this->collTaxRuleCountries->append($obj); + } } - } - $this->collTaxRuleCountrysPartial = true; + $this->collTaxRuleCountriesPartial = true; } - $collTaxRuleCountrys->getInternalIterator()->rewind(); - return $collTaxRuleCountrys; + $collTaxRuleCountries->getInternalIterator()->rewind(); + + return $collTaxRuleCountries; } - if($partial && $this->collTaxRuleCountrys) { - foreach($this->collTaxRuleCountrys as $obj) { - if($obj->isNew()) { - $collTaxRuleCountrys[] = $obj; + if ($partial && $this->collTaxRuleCountries) { + foreach ($this->collTaxRuleCountries as $obj) { + if ($obj->isNew()) { + $collTaxRuleCountries[] = $obj; } } } - $this->collTaxRuleCountrys = $collTaxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; + $this->collTaxRuleCountries = $collTaxRuleCountries; + $this->collTaxRuleCountriesPartial = false; } } - return $this->collTaxRuleCountrys; + return $this->collTaxRuleCountries; } /** @@ -1466,27 +1577,28 @@ abstract class BaseCountry extends BaseObject implements Persistent * It will 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) + * @param Collection $taxRuleCountries A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCountry The current object (for fluent API support) */ - public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null) + public function setTaxRuleCountries(Collection $taxRuleCountries, ConnectionInterface $con = null) { - $taxRuleCountrysToDelete = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); + $taxRuleCountriesToDelete = $this->getTaxRuleCountries(new Criteria(), $con)->diff($taxRuleCountries); - $this->taxRuleCountrysScheduledForDeletion = unserialize(serialize($taxRuleCountrysToDelete)); - foreach ($taxRuleCountrysToDelete as $taxRuleCountryRemoved) { + $this->taxRuleCountriesScheduledForDeletion = $taxRuleCountriesToDelete; + + foreach ($taxRuleCountriesToDelete as $taxRuleCountryRemoved) { $taxRuleCountryRemoved->setCountry(null); } - $this->collTaxRuleCountrys = null; - foreach ($taxRuleCountrys as $taxRuleCountry) { + $this->collTaxRuleCountries = null; + foreach ($taxRuleCountries as $taxRuleCountry) { $this->addTaxRuleCountry($taxRuleCountry); } - $this->collTaxRuleCountrys = $taxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; + $this->collTaxRuleCountries = $taxRuleCountries; + $this->collTaxRuleCountriesPartial = false; return $this; } @@ -1494,24 +1606,25 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Returns the number of related TaxRuleCountry objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related TaxRuleCountry objects. * @throws PropelException */ - public function countTaxRuleCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countTaxRuleCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { + $partial = $this->collTaxRuleCountriesPartial && !$this->isNew(); + if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTaxRuleCountries) { return 0; } - if($partial && !$criteria) { - return count($this->getTaxRuleCountrys()); + if ($partial && !$criteria) { + return count($this->getTaxRuleCountries()); } - $query = TaxRuleCountryQuery::create(null, $criteria); + + $query = ChildTaxRuleCountryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1521,23 +1634,24 @@ abstract class BaseCountry extends BaseObject implements Persistent ->count($con); } - return count($this->collTaxRuleCountrys); + return count($this->collTaxRuleCountries); } /** - * Method called to associate a TaxRuleCountry object to this object - * through the TaxRuleCountry foreign key attribute. + * Method called to associate a ChildTaxRuleCountry object to this object + * through the ChildTaxRuleCountry foreign key attribute. * - * @param TaxRuleCountry $l TaxRuleCountry - * @return Country The current object (for fluent API support) + * @param ChildTaxRuleCountry $l ChildTaxRuleCountry + * @return \Thelia\Model\Country The current object (for fluent API support) */ - public function addTaxRuleCountry(TaxRuleCountry $l) + public function addTaxRuleCountry(ChildTaxRuleCountry $l) { - if ($this->collTaxRuleCountrys === null) { - $this->initTaxRuleCountrys(); - $this->collTaxRuleCountrysPartial = true; + if ($this->collTaxRuleCountries === null) { + $this->initTaxRuleCountries(); + $this->collTaxRuleCountriesPartial = true; } - if (!in_array($l, $this->collTaxRuleCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collTaxRuleCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddTaxRuleCountry($l); } @@ -1545,27 +1659,27 @@ abstract class BaseCountry extends BaseObject implements Persistent } /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add. + * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add. */ protected function doAddTaxRuleCountry($taxRuleCountry) { - $this->collTaxRuleCountrys[]= $taxRuleCountry; + $this->collTaxRuleCountries[]= $taxRuleCountry; $taxRuleCountry->setCountry($this); } /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. - * @return Country The current object (for fluent API support) + * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. + * @return ChildCountry 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(); + if ($this->getTaxRuleCountries()->contains($taxRuleCountry)) { + $this->collTaxRuleCountries->remove($this->collTaxRuleCountries->search($taxRuleCountry)); + if (null === $this->taxRuleCountriesScheduledForDeletion) { + $this->taxRuleCountriesScheduledForDeletion = clone $this->collTaxRuleCountries; + $this->taxRuleCountriesScheduledForDeletion->clear(); } - $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry; + $this->taxRuleCountriesScheduledForDeletion[]= $taxRuleCountry; $taxRuleCountry->setCountry(null); } @@ -1578,23 +1692,23 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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. + * been saved, it will retrieve related TaxRuleCountries from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects */ - public function getTaxRuleCountrysJoinTax($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getTaxRuleCountriesJoinTax($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('Tax', $join_behavior); + $query = ChildTaxRuleCountryQuery::create(null, $criteria); + $query->joinWith('Tax', $joinBehavior); - return $this->getTaxRuleCountrys($query, $con); + return $this->getTaxRuleCountries($query, $con); } @@ -1603,23 +1717,23 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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. + * been saved, it will retrieve related TaxRuleCountries from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects */ - public function getTaxRuleCountrysJoinTaxRule($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getTaxRuleCountriesJoinTaxRule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('TaxRule', $join_behavior); + $query = ChildTaxRuleCountryQuery::create(null, $criteria); + $query->joinWith('TaxRule', $joinBehavior); - return $this->getTaxRuleCountrys($query, $con); + return $this->getTaxRuleCountries($query, $con); } /** @@ -1628,21 +1742,16 @@ abstract class BaseCountry extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collCountryI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collCountryI18ns collection loaded partially - * - * @return void + * Reset is the collCountryI18ns collection loaded partially. */ public function resetPartialCountryI18ns($v = true) { @@ -1656,7 +1765,7 @@ abstract class BaseCountry extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1666,25 +1775,25 @@ abstract class BaseCountry extends BaseObject implements Persistent if (null !== $this->collCountryI18ns && !$overrideExisting) { return; } - $this->collCountryI18ns = new PropelObjectCollection(); - $this->collCountryI18ns->setModel('CountryI18n'); + $this->collCountryI18ns = new ObjectCollection(); + $this->collCountryI18ns->setModel('\Thelia\Model\CountryI18n'); } /** - * Gets an array of CountryI18n objects which contain a foreign key that references this object. + * Gets an array of ChildCountryI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCountry is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCountryI18n[] List of ChildCountryI18n objects * @throws PropelException */ - public function getCountryI18ns($criteria = null, PropelPDO $con = null) + public function getCountryI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collCountryI18nsPartial && !$this->isNew(); if (null === $this->collCountryI18ns || null !== $criteria || $partial) { @@ -1692,29 +1801,31 @@ abstract class BaseCountry extends BaseObject implements Persistent // return empty collection $this->initCountryI18ns(); } else { - $collCountryI18ns = CountryI18nQuery::create(null, $criteria) + $collCountryI18ns = ChildCountryI18nQuery::create(null, $criteria) ->filterByCountry($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collCountryI18nsPartial && count($collCountryI18ns)) { - $this->initCountryI18ns(false); + $this->initCountryI18ns(false); - foreach($collCountryI18ns as $obj) { - if (false == $this->collCountryI18ns->contains($obj)) { - $this->collCountryI18ns->append($obj); + foreach ($collCountryI18ns as $obj) { + if (false == $this->collCountryI18ns->contains($obj)) { + $this->collCountryI18ns->append($obj); + } } - } - $this->collCountryI18nsPartial = true; + $this->collCountryI18nsPartial = true; } $collCountryI18ns->getInternalIterator()->rewind(); + return $collCountryI18ns; } - if($partial && $this->collCountryI18ns) { - foreach($this->collCountryI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collCountryI18ns) { + foreach ($this->collCountryI18ns as $obj) { + if ($obj->isNew()) { $collCountryI18ns[] = $obj; } } @@ -1734,15 +1845,19 @@ abstract class BaseCountry extends BaseObject implements Persistent * It will 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) + * @param Collection $countryI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCountry The current object (for fluent API support) */ - public function setCountryI18ns(PropelCollection $countryI18ns, PropelPDO $con = null) + public function setCountryI18ns(Collection $countryI18ns, ConnectionInterface $con = null) { $countryI18nsToDelete = $this->getCountryI18ns(new Criteria(), $con)->diff($countryI18ns); - $this->countryI18nsScheduledForDeletion = unserialize(serialize($countryI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->countryI18nsScheduledForDeletion = clone $countryI18nsToDelete; foreach ($countryI18nsToDelete as $countryI18nRemoved) { $countryI18nRemoved->setCountry(null); @@ -1762,13 +1877,13 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Returns the number of related CountryI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related CountryI18n objects. * @throws PropelException */ - public function countCountryI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countCountryI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collCountryI18nsPartial && !$this->isNew(); if (null === $this->collCountryI18ns || null !== $criteria || $partial) { @@ -1776,10 +1891,11 @@ abstract class BaseCountry extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getCountryI18ns()); } - $query = CountryI18nQuery::create(null, $criteria); + + $query = ChildCountryI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1793,13 +1909,13 @@ abstract class BaseCountry extends BaseObject implements Persistent } /** - * Method called to associate a CountryI18n object to this object - * through the CountryI18n foreign key attribute. + * Method called to associate a ChildCountryI18n object to this object + * through the ChildCountryI18n foreign key attribute. * - * @param CountryI18n $l CountryI18n - * @return Country The current object (for fluent API support) + * @param ChildCountryI18n $l ChildCountryI18n + * @return \Thelia\Model\Country The current object (for fluent API support) */ - public function addCountryI18n(CountryI18n $l) + public function addCountryI18n(ChildCountryI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1809,6 +1925,7 @@ abstract class BaseCountry extends BaseObject implements Persistent $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); } @@ -1817,7 +1934,7 @@ abstract class BaseCountry extends BaseObject implements Persistent } /** - * @param CountryI18n $countryI18n The countryI18n object to add. + * @param CountryI18n $countryI18n The countryI18n object to add. */ protected function doAddCountryI18n($countryI18n) { @@ -1826,8 +1943,8 @@ abstract class BaseCountry extends BaseObject implements Persistent } /** - * @param CountryI18n $countryI18n The countryI18n object to remove. - * @return Country The current object (for fluent API support) + * @param CountryI18n $countryI18n The countryI18n object to remove. + * @return ChildCountry The current object (for fluent API support) */ public function removeCountryI18n($countryI18n) { @@ -1857,8 +1974,6 @@ abstract class BaseCountry extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1870,16 +1985,15 @@ abstract class BaseCountry extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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) { + if ($deep) { + if ($this->collTaxRuleCountries) { + foreach ($this->collTaxRuleCountries as $o) { $o->clearAllReferences($deep); } } @@ -1888,22 +2002,17 @@ abstract class BaseCountry extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->aArea instanceof Persistent) { - $this->aArea->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collTaxRuleCountrys instanceof PropelCollection) { - $this->collTaxRuleCountrys->clearIterator(); + if ($this->collTaxRuleCountries instanceof Collection) { + $this->collTaxRuleCountries->clearIterator(); } - $this->collTaxRuleCountrys = null; - if ($this->collCountryI18ns instanceof PropelCollection) { + $this->collTaxRuleCountries = null; + if ($this->collCountryI18ns instanceof Collection) { $this->collCountryI18ns->clearIterator(); } $this->collCountryI18ns = null; @@ -1911,23 +2020,13 @@ abstract class BaseCountry extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(CountryTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1935,11 +2034,11 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * 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) + * @return ChildCountry The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = CountryPeer::UPDATED_AT; + $this->modifiedColumns[] = CountryTableMap::UPDATED_AT; return $this; } @@ -1951,9 +2050,9 @@ abstract class BaseCountry extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Country The current object (for fluent API support) + * @return ChildCountry The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1974,10 +2073,10 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return CountryI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildCountryI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCountryI18ns) { @@ -1990,10 +2089,10 @@ abstract class BaseCountry extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new CountryI18n(); + $translation = new ChildCountryI18n(); $translation->setLocale($locale); } else { - $translation = CountryI18nQuery::create() + $translation = ChildCountryI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -2008,14 +2107,14 @@ abstract class BaseCountry extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Country The current object (for fluent API support) + * @return ChildCountry The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - CountryI18nQuery::create() + ChildCountryI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -2035,10 +2134,10 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return CountryI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildCountryI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -2047,7 +2146,7 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -2058,8 +2157,8 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CountryI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2071,7 +2170,7 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -2082,8 +2181,8 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CountryI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2095,7 +2194,7 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -2106,8 +2205,8 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CountryI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2119,7 +2218,7 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -2130,8 +2229,8 @@ abstract class BaseCountry extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CountryI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -2139,4 +2238,122 @@ abstract class BaseCountry extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/CountryI18n.php b/core/lib/Thelia/Model/Base/CountryI18n.php new file mode 100644 index 000000000..270a9d3f7 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CountryI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\CountryI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CountryI18n instance. If + * obj is an instance of CountryI18n, delegates to + * equals(CountryI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CountryI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CountryI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\CountryI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CountryI18nTableMap::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 \Thelia\Model\CountryI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = CountryI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\CountryI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = CountryI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\CountryI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = CountryI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\CountryI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = CountryI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\CountryI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = CountryI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CountryI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CountryI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CountryI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CountryI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CountryI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CountryI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = CountryI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CountryI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(CountryI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCountryI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCountry = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CountryI18n::setDeleted() + * @see CountryI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCountryI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME); + } + + $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); + CountryI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CountryI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CountryI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(CountryI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(CountryI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(CountryI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(CountryI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CountryI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CountryI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CountryI18n'][serialize($this->getPrimaryKey())] = true; + $keys = CountryI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CountryI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = CountryI18nTableMap::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(CountryI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CountryI18nTableMap::ID)) $criteria->add(CountryI18nTableMap::ID, $this->id); + if ($this->isColumnModified(CountryI18nTableMap::LOCALE)) $criteria->add(CountryI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(CountryI18nTableMap::TITLE)) $criteria->add(CountryI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(CountryI18nTableMap::DESCRIPTION)) $criteria->add(CountryI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(CountryI18nTableMap::CHAPO)) $criteria->add(CountryI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(CountryI18nTableMap::POSTSCRIPTUM)) $criteria->add(CountryI18nTableMap::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(CountryI18nTableMap::DATABASE_NAME); + $criteria->add(CountryI18nTableMap::ID, $this->id); + $criteria->add(CountryI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildCountry object. + * + * @param ChildCountry $v + * @return \Thelia\Model\CountryI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setCountry(ChildCountry $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 ChildCountry object, it will not be re-added. + if ($v !== null) { + $v->addCountryI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCountry object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCountry The associated ChildCountry object. + * @throws PropelException + */ + public function getCountry(ConnectionInterface $con = null) + { + if ($this->aCountry === null && ($this->id !== null)) { + $this->aCountry = ChildCountryQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCountry = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CountryI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseCountryI18nQuery.php b/core/lib/Thelia/Model/Base/CountryI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseCountryI18nQuery.php rename to core/lib/Thelia/Model/Base/CountryI18nQuery.php index ed1ff2f7a..924ed263a --- a/core/lib/Thelia/Model/om/BaseCountryI18nQuery.php +++ b/core/lib/Thelia/Model/Base/CountryI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return CountryI18n|CountryI18n[]|mixed the result, formatted by the current formatter + * @return ChildCountryI18n|array|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 + if ((null !== ($obj = CountryI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CountryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CountryI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return CountryI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildCountryI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `country_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseCountryI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CountryI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCountryI18n(); $obj->hydrate($row); - CountryI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + CountryI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return CountryI18n|CountryI18n[]|mixed the result, formatted by the current formatter + * @return ChildCountryI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|CountryI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CountryI18nQuery The current query, for fluid interface + * @return ChildCountryI18nQuery 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); + $this->addUsingAlias(CountryI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CountryI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CountryI18nQuery The current query, for fluid interface + * @return ChildCountryI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseCountryI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(CountryI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CountryI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByCountry() @@ -270,18 +266,18 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * 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 + * @return ChildCountryI18nQuery 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); + $this->addUsingAlias(CountryI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CountryI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CountryI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(CountryI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * 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 + * @return ChildCountryI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(CountryI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * 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 + * @return ChildCountryI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(CountryI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * 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 + * @return ChildCountryI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(CountryI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * 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 + * @return ChildCountryI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(CountryI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * 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 + * @return ChildCountryI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseCountryI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(CountryI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Country object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Country|ObjectCollection $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. + * @return ChildCountryI18nQuery The current query, for fluid interface */ public function filterByCountry($country, $comparison = null) { - if ($country instanceof Country) { + if ($country instanceof \Thelia\Model\Country) { return $this - ->addUsingAlias(CountryI18nPeer::ID, $country->getId(), $comparison); - } elseif ($country instanceof PropelObjectCollection) { + ->addUsingAlias(CountryI18nTableMap::ID, $country->getId(), $comparison); + } elseif ($country instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(CountryI18nPeer::ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(CountryI18nTableMap::ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection'); + throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria * @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 + * @return ChildCountryI18nQuery The current query, for fluid interface */ public function joinCountry($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseCountryI18nQuery extends ModelCriteria /** * Use the Country relation Country object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseCountryI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param CountryI18n $countryI18n Object to remove from the list of results + * @param ChildCountryI18n $countryI18n Object to remove from the list of results * - * @return CountryI18nQuery The current query, for fluid interface + * @return ChildCountryI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(CountryI18nTableMap::ID), $countryI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CountryI18nTableMap::LOCALE), $countryI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the country_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CountryI18nTableMap::clearInstancePool(); + CountryI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCountryI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCountryI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CountryI18nTableMap::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(); + + + CountryI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CountryI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CountryI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseCountryQuery.php b/core/lib/Thelia/Model/Base/CountryQuery.php old mode 100755 new mode 100644 similarity index 56% rename from core/lib/Thelia/Model/om/BaseCountryQuery.php rename to core/lib/Thelia/Model/Base/CountryQuery.php index 24c22c0b7..1b5c02209 --- a/core/lib/Thelia/Model/om/BaseCountryQuery.php +++ b/core/lib/Thelia/Model/Base/CountryQuery.php @@ -1,109 +1,108 @@ setModelAlias($modelAlias); } @@ -124,21 +123,21 @@ abstract class BaseCountryQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Country|Country[]|mixed the result, formatted by the current formatter + * @return ChildCountry|array|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 + if ((null !== ($obj = CountryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CountryTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -150,46 +149,31 @@ abstract class BaseCountryQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Country A model object, or null if the key is not found - * @throws PropelException + * @return ChildCountry A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at` FROM `country` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Country(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCountry(); $obj->hydrate($row); - CountryPeer::addInstanceToPool($obj, (string) $key); + CountryTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -200,19 +184,19 @@ abstract class BaseCountryQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Country|Country[]|mixed the result, formatted by the current formatter + * @return ChildCountry|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -221,22 +205,22 @@ abstract class BaseCountryQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Country[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -244,12 +228,12 @@ abstract class BaseCountryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CountryQuery The current query, for fluid interface + * @return ChildCountryQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(CountryPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(CountryTableMap::ID, $key, Criteria::EQUAL); } /** @@ -257,12 +241,12 @@ abstract class BaseCountryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CountryQuery The current query, for fluid interface + * @return ChildCountryQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(CountryPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(CountryTableMap::ID, $keys, Criteria::IN); } /** @@ -272,8 +256,7 @@ abstract class BaseCountryQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -282,18 +265,18 @@ abstract class BaseCountryQuery extends ModelCriteria * 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 + * @return ChildCountryQuery 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); + $this->addUsingAlias(CountryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CountryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CountryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -304,7 +287,7 @@ abstract class BaseCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryPeer::ID, $id, $comparison); + return $this->addUsingAlias(CountryTableMap::ID, $id, $comparison); } /** @@ -314,8 +297,7 @@ abstract class BaseCountryQuery extends ModelCriteria * * $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 + * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12 * * * @see filterByArea() @@ -326,18 +308,18 @@ abstract class BaseCountryQuery extends ModelCriteria * 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 + * @return ChildCountryQuery 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); + $this->addUsingAlias(CountryTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($areaId['max'])) { - $this->addUsingAlias(CountryPeer::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CountryTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -348,7 +330,7 @@ abstract class BaseCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryPeer::AREA_ID, $areaId, $comparison); + return $this->addUsingAlias(CountryTableMap::AREA_ID, $areaId, $comparison); } /** @@ -364,7 +346,7 @@ abstract class BaseCountryQuery extends ModelCriteria * 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 + * @return ChildCountryQuery The current query, for fluid interface */ public function filterByIsocode($isocode = null, $comparison = null) { @@ -377,7 +359,7 @@ abstract class BaseCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryPeer::ISOCODE, $isocode, $comparison); + return $this->addUsingAlias(CountryTableMap::ISOCODE, $isocode, $comparison); } /** @@ -393,7 +375,7 @@ abstract class BaseCountryQuery extends ModelCriteria * 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 + * @return ChildCountryQuery The current query, for fluid interface */ public function filterByIsoalpha2($isoalpha2 = null, $comparison = null) { @@ -406,7 +388,7 @@ abstract class BaseCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryPeer::ISOALPHA2, $isoalpha2, $comparison); + return $this->addUsingAlias(CountryTableMap::ISOALPHA2, $isoalpha2, $comparison); } /** @@ -422,7 +404,7 @@ abstract class BaseCountryQuery extends ModelCriteria * 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 + * @return ChildCountryQuery The current query, for fluid interface */ public function filterByIsoalpha3($isoalpha3 = null, $comparison = null) { @@ -435,7 +417,7 @@ abstract class BaseCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryPeer::ISOALPHA3, $isoalpha3, $comparison); + return $this->addUsingAlias(CountryTableMap::ISOALPHA3, $isoalpha3, $comparison); } /** @@ -456,18 +438,18 @@ abstract class BaseCountryQuery extends ModelCriteria * 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 + * @return ChildCountryQuery 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); + $this->addUsingAlias(CountryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CountryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CountryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -478,7 +460,7 @@ abstract class BaseCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CountryTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -499,18 +481,18 @@ abstract class BaseCountryQuery extends ModelCriteria * 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 + * @return ChildCountryQuery 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); + $this->addUsingAlias(CountryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CountryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CountryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -521,32 +503,31 @@ abstract class BaseCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(CountryPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CountryTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Area object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Area|ObjectCollection $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. + * @return ChildCountryQuery The current query, for fluid interface */ public function filterByArea($area, $comparison = null) { - if ($area instanceof Area) { + if ($area instanceof \Thelia\Model\Area) { return $this - ->addUsingAlias(CountryPeer::AREA_ID, $area->getId(), $comparison); - } elseif ($area instanceof PropelObjectCollection) { + ->addUsingAlias(CountryTableMap::AREA_ID, $area->getId(), $comparison); + } elseif ($area instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(CountryPeer::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(CountryTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByArea() only accepts arguments of type Area or PropelCollection'); + throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection'); } } @@ -556,7 +537,7 @@ abstract class BaseCountryQuery extends ModelCriteria * @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 + * @return ChildCountryQuery The current query, for fluid interface */ public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -585,7 +566,7 @@ abstract class BaseCountryQuery extends ModelCriteria /** * Use the Area relation Area object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -601,26 +582,25 @@ abstract class BaseCountryQuery extends ModelCriteria } /** - * Filter the query by a related TaxRuleCountry object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\TaxRuleCountry|ObjectCollection $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. + * @return ChildCountryQuery The current query, for fluid interface */ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) { - if ($taxRuleCountry instanceof TaxRuleCountry) { + if ($taxRuleCountry instanceof \Thelia\Model\TaxRuleCountry) { return $this - ->addUsingAlias(CountryPeer::ID, $taxRuleCountry->getCountryId(), $comparison); - } elseif ($taxRuleCountry instanceof PropelObjectCollection) { + ->addUsingAlias(CountryTableMap::ID, $taxRuleCountry->getCountryId(), $comparison); + } elseif ($taxRuleCountry instanceof ObjectCollection) { return $this ->useTaxRuleCountryQuery() ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection'); + throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type \Thelia\Model\TaxRuleCountry or Collection'); } } @@ -630,7 +610,7 @@ abstract class BaseCountryQuery extends ModelCriteria * @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 + * @return ChildCountryQuery The current query, for fluid interface */ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -659,7 +639,7 @@ abstract class BaseCountryQuery extends ModelCriteria /** * Use the TaxRuleCountry relation TaxRuleCountry object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -675,26 +655,25 @@ abstract class BaseCountryQuery extends ModelCriteria } /** - * Filter the query by a related CountryI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\CountryI18n|ObjectCollection $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. + * @return ChildCountryQuery The current query, for fluid interface */ public function filterByCountryI18n($countryI18n, $comparison = null) { - if ($countryI18n instanceof CountryI18n) { + if ($countryI18n instanceof \Thelia\Model\CountryI18n) { return $this - ->addUsingAlias(CountryPeer::ID, $countryI18n->getId(), $comparison); - } elseif ($countryI18n instanceof PropelObjectCollection) { + ->addUsingAlias(CountryTableMap::ID, $countryI18n->getId(), $comparison); + } elseif ($countryI18n instanceof ObjectCollection) { return $this ->useCountryI18nQuery() ->filterByPrimaryKeys($countryI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCountryI18n() only accepts arguments of type CountryI18n or PropelCollection'); + throw new PropelException('filterByCountryI18n() only accepts arguments of type \Thelia\Model\CountryI18n or Collection'); } } @@ -704,7 +683,7 @@ abstract class BaseCountryQuery extends ModelCriteria * @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 + * @return ChildCountryQuery The current query, for fluid interface */ public function joinCountryI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -733,7 +712,7 @@ abstract class BaseCountryQuery extends ModelCriteria /** * Use the CountryI18n relation CountryI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -751,19 +730,94 @@ abstract class BaseCountryQuery extends ModelCriteria /** * Exclude object from result * - * @param Country $country Object to remove from the list of results + * @param ChildCountry $country Object to remove from the list of results * - * @return CountryQuery The current query, for fluid interface + * @return ChildCountryQuery The current query, for fluid interface */ public function prune($country = null) { if ($country) { - $this->addUsingAlias(CountryPeer::ID, $country->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(CountryTableMap::ID, $country->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the country table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CountryTableMap::clearInstancePool(); + CountryTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCountry or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCountry object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CountryTableMap::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(); + + + CountryTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CountryTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -771,31 +825,11 @@ abstract class BaseCountryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return CountryQuery The current query, for fluid interface + * @return ChildCountryQuery 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); + return $this->addUsingAlias(CountryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -803,32 +837,53 @@ abstract class BaseCountryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return CountryQuery The current query, for fluid interface + * @return ChildCountryQuery 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); + return $this->addUsingAlias(CountryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCountryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CountryTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCountryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CountryTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return CountryQuery The current query, for fluid interface + * @return ChildCountryQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(CountryPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(CountryTableMap::CREATED_AT); } /** * Order by create date asc * - * @return CountryQuery The current query, for fluid interface + * @return ChildCountryQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(CountryPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(CountryTableMap::CREATED_AT); } + // i18n behavior /** @@ -838,9 +893,9 @@ abstract class BaseCountryQuery extends ModelCriteria * @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 + * @return ChildCountryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CountryI18n'; @@ -856,9 +911,9 @@ abstract class BaseCountryQuery extends ModelCriteria * @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 + * @return ChildCountryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -877,13 +932,13 @@ abstract class BaseCountryQuery extends ModelCriteria * @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 + * @return ChildCountryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CountryI18n', 'Thelia\Model\CountryI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'CountryI18n', '\Thelia\Model\CountryI18nQuery'); } -} +} // CountryQuery diff --git a/core/lib/Thelia/Model/om/BaseCoupon.php b/core/lib/Thelia/Model/Base/Coupon.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseCoupon.php rename to core/lib/Thelia/Model/Base/Coupon.php index 345437ab2..2c3dae5c9 --- a/core/lib/Thelia/Model/om/BaseCoupon.php +++ b/core/lib/Thelia/Model/Base/Coupon.php @@ -1,53 +1,61 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Coupon instance. If + * obj is an instance of Coupon, delegates to + * equals(Coupon). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Coupon The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Coupon The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [code] column value. * - * @return string + * @return string */ public function getCode() { + return $this->code; } /** * Get the [action] column value. * - * @return string + * @return string */ public function getAction() { + return $this->action; } /** * Get the [value] column value. * - * @return double + * @return double */ public function getValue() { + return $this->value; } /** * Get the [used] column value. * - * @return int + * @return int */ public function getUsed() { + return $this->used; } @@ -195,89 +450,50 @@ abstract class BaseCoupon extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getAvailableSince($format = NULL) { - 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; + return $this->available_since; + } else { + return $this->available_since !== null ? $this->available_since->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getDateLimit($format = NULL) { - 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; + return $this->date_limit; + } else { + return $this->date_limit !== null ? $this->date_limit->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [activate] column value. * - * @return int + * @return int */ public function getActivate() { + return $this->activate; } @@ -285,97 +501,57 @@ abstract class BaseCoupon extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = CouponPeer::ID; + $this->modifiedColumns[] = CouponTableMap::ID; } @@ -385,18 +561,18 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Set the value of [code] column. * - * @param string $v new value - * @return Coupon The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setCode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->code !== $v) { $this->code = $v; - $this->modifiedColumns[] = CouponPeer::CODE; + $this->modifiedColumns[] = CouponTableMap::CODE; } @@ -406,18 +582,18 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Set the value of [action] column. * - * @param string $v new value - * @return Coupon The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setAction($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->action !== $v) { $this->action = $v; - $this->modifiedColumns[] = CouponPeer::ACTION; + $this->modifiedColumns[] = CouponTableMap::ACTION; } @@ -427,18 +603,18 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Set the value of [value] column. * - * @param double $v new value - * @return Coupon The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setValue($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->value !== $v) { $this->value = $v; - $this->modifiedColumns[] = CouponPeer::VALUE; + $this->modifiedColumns[] = CouponTableMap::VALUE; } @@ -448,18 +624,18 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Set the value of [used] column. * - * @param int $v new value - * @return Coupon The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setUsed($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->used !== $v) { $this->used = $v; - $this->modifiedColumns[] = CouponPeer::USED; + $this->modifiedColumns[] = CouponTableMap::USED; } @@ -469,19 +645,17 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setAvailableSince($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->available_since) { + $this->available_since = $dt; + $this->modifiedColumns[] = CouponTableMap::AVAILABLE_SINCE; } } // if either are not null @@ -492,19 +666,17 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setDateLimit($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->date_limit) { + $this->date_limit = $dt; + $this->modifiedColumns[] = CouponTableMap::DATE_LIMIT; } } // if either are not null @@ -515,18 +687,18 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Set the value of [activate] column. * - * @param int $v new value - * @return Coupon The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setActivate($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->activate !== $v) { $this->activate = $v; - $this->modifiedColumns[] = CouponPeer::ACTIVATE; + $this->modifiedColumns[] = CouponTableMap::ACTIVATE; } @@ -536,19 +708,17 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CouponTableMap::CREATED_AT; } } // if either are not null @@ -559,19 +729,17 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CouponTableMap::UPDATED_AT; } } // if either are not null @@ -589,7 +757,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -601,26 +769,62 @@ abstract class BaseCoupon extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponTableMap::translateFieldName('Action', TableMap::TYPE_PHPNAME, $indexType)]; + $this->action = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $this->value = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponTableMap::translateFieldName('Used', TableMap::TYPE_PHPNAME, $indexType)]; + $this->used = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponTableMap::translateFieldName('AvailableSince', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->available_since = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponTableMap::translateFieldName('DateLimit', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->date_limit = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CouponTableMap::translateFieldName('Activate', TableMap::TYPE_PHPNAME, $indexType)]; + $this->activate = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -628,11 +832,11 @@ abstract class BaseCoupon extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 10; // 10 = CouponPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 10; // 10 = CouponTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Coupon object", $e); + throw new PropelException("Error populating \Thelia\Model\Coupon object", 0, $e); } } @@ -651,7 +855,6 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -659,12 +862,12 @@ abstract class BaseCoupon extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -675,19 +878,19 @@ abstract class BaseCoupon extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CouponTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildCouponQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -699,26 +902,25 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Coupon::setDeleted() + * @see Coupon::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = CouponQuery::create() + $deleteQuery = ChildCouponQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -743,20 +945,19 @@ abstract class BaseCoupon extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -766,16 +967,16 @@ abstract class BaseCoupon extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(CouponPeer::CREATED_AT)) { + if (!$this->isColumnModified(CouponTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(CouponPeer::UPDATED_AT)) { + if (!$this->isColumnModified(CouponTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CouponPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(CouponTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -787,7 +988,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - CouponPeer::addInstanceToPool($this); + CouponTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -806,12 +1007,12 @@ abstract class BaseCoupon extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -830,15 +1031,15 @@ abstract class BaseCoupon extends BaseObject implements Persistent if ($this->couponRulesScheduledForDeletion !== null) { if (!$this->couponRulesScheduledForDeletion->isEmpty()) { - CouponRuleQuery::create() + \Thelia\Model\CouponRuleQuery::create() ->filterByPrimaryKeys($this->couponRulesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->couponRulesScheduledForDeletion = null; } } - if ($this->collCouponRules !== null) { - foreach ($this->collCouponRules as $referrerFK) { + if ($this->collCouponRules !== null) { + foreach ($this->collCouponRules as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -855,55 +1056,55 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = CouponPeer::ID; + $this->modifiedColumns[] = CouponTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CouponPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(CouponTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(CouponPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; + if ($this->isColumnModified(CouponTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(CouponPeer::ACTION)) { - $modifiedColumns[':p' . $index++] = '`action`'; + if ($this->isColumnModified(CouponTableMap::ACTION)) { + $modifiedColumns[':p' . $index++] = 'ACTION'; } - if ($this->isColumnModified(CouponPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`value`'; + if ($this->isColumnModified(CouponTableMap::VALUE)) { + $modifiedColumns[':p' . $index++] = 'VALUE'; } - if ($this->isColumnModified(CouponPeer::USED)) { - $modifiedColumns[':p' . $index++] = '`used`'; + if ($this->isColumnModified(CouponTableMap::USED)) { + $modifiedColumns[':p' . $index++] = 'USED'; } - if ($this->isColumnModified(CouponPeer::AVAILABLE_SINCE)) { - $modifiedColumns[':p' . $index++] = '`available_since`'; + if ($this->isColumnModified(CouponTableMap::AVAILABLE_SINCE)) { + $modifiedColumns[':p' . $index++] = 'AVAILABLE_SINCE'; } - if ($this->isColumnModified(CouponPeer::DATE_LIMIT)) { - $modifiedColumns[':p' . $index++] = '`date_limit`'; + if ($this->isColumnModified(CouponTableMap::DATE_LIMIT)) { + $modifiedColumns[':p' . $index++] = 'DATE_LIMIT'; } - if ($this->isColumnModified(CouponPeer::ACTIVATE)) { - $modifiedColumns[':p' . $index++] = '`activate`'; + if ($this->isColumnModified(CouponTableMap::ACTIVATE)) { + $modifiedColumns[':p' . $index++] = 'ACTIVATE'; } - if ($this->isColumnModified(CouponPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(CouponTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(CouponPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `coupon` (%s) VALUES (%s)', + 'INSERT INTO coupon (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -912,48 +1113,48 @@ abstract class BaseCoupon extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`code`': + case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`action`': + case 'ACTION': $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR); break; - case '`value`': + case 'VALUE': $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); break; - case '`used`': + case 'USED': $stmt->bindValue($identifier, $this->used, PDO::PARAM_INT); break; - case '`available_since`': - $stmt->bindValue($identifier, $this->available_since, PDO::PARAM_STR); + case 'AVAILABLE_SINCE': + $stmt->bindValue($identifier, $this->available_since ? $this->available_since->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`date_limit`': - $stmt->bindValue($identifier, $this->date_limit, PDO::PARAM_STR); + case 'DATE_LIMIT': + $stmt->bindValue($identifier, $this->date_limit ? $this->date_limit->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`activate`': + case 'ACTIVATE': $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -963,112 +1164,32 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = CouponPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CouponTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1078,7 +1199,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1126,22 +1247,22 @@ abstract class BaseCoupon extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = CouponTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), @@ -1154,6 +1275,12 @@ abstract class BaseCoupon extends BaseObject implements Persistent $keys[8] => $this->getCreatedAt(), $keys[9] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collCouponRules) { $result['CouponRules'] = $this->collCouponRules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1166,27 +1293,27 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = CouponPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CouponTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1234,17 +1361,17 @@ abstract class BaseCoupon extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = CouponPeer::getFieldNames($keyType); + $keys = CouponTableMap::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]]); @@ -1265,18 +1392,18 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(CouponPeer::DATABASE_NAME); + $criteria = new Criteria(CouponTableMap::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); + if ($this->isColumnModified(CouponTableMap::ID)) $criteria->add(CouponTableMap::ID, $this->id); + if ($this->isColumnModified(CouponTableMap::CODE)) $criteria->add(CouponTableMap::CODE, $this->code); + if ($this->isColumnModified(CouponTableMap::ACTION)) $criteria->add(CouponTableMap::ACTION, $this->action); + if ($this->isColumnModified(CouponTableMap::VALUE)) $criteria->add(CouponTableMap::VALUE, $this->value); + if ($this->isColumnModified(CouponTableMap::USED)) $criteria->add(CouponTableMap::USED, $this->used); + if ($this->isColumnModified(CouponTableMap::AVAILABLE_SINCE)) $criteria->add(CouponTableMap::AVAILABLE_SINCE, $this->available_since); + if ($this->isColumnModified(CouponTableMap::DATE_LIMIT)) $criteria->add(CouponTableMap::DATE_LIMIT, $this->date_limit); + if ($this->isColumnModified(CouponTableMap::ACTIVATE)) $criteria->add(CouponTableMap::ACTIVATE, $this->activate); + if ($this->isColumnModified(CouponTableMap::CREATED_AT)) $criteria->add(CouponTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CouponTableMap::UPDATED_AT)) $criteria->add(CouponTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1291,15 +1418,15 @@ abstract class BaseCoupon extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(CouponPeer::DATABASE_NAME); - $criteria->add(CouponPeer::ID, $this->id); + $criteria = new Criteria(CouponTableMap::DATABASE_NAME); + $criteria->add(CouponTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1309,7 +1436,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1333,9 +1460,9 @@ abstract class BaseCoupon extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1350,12 +1477,10 @@ abstract class BaseCoupon extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1363,8 +1488,6 @@ abstract class BaseCoupon extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1381,8 +1504,8 @@ abstract class BaseCoupon extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Coupon Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1395,37 +1518,19 @@ abstract class BaseCoupon extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('CouponRule' == $relationName) { - $this->initCouponRules(); + return $this->initCouponRules(); } } @@ -1435,21 +1540,16 @@ abstract class BaseCoupon extends BaseObject implements Persistent * This 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) + * @return void * @see addCouponRules() */ public function clearCouponRules() { - $this->collCouponRules = null; // important to set this to null since that means it is uninitialized - $this->collCouponRulesPartial = null; - - return $this; + $this->collCouponRules = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collCouponRules collection loaded partially - * - * @return void + * Reset is the collCouponRules collection loaded partially. */ public function resetPartialCouponRules($v = true) { @@ -1463,7 +1563,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1473,25 +1573,25 @@ abstract class BaseCoupon extends BaseObject implements Persistent if (null !== $this->collCouponRules && !$overrideExisting) { return; } - $this->collCouponRules = new PropelObjectCollection(); - $this->collCouponRules->setModel('CouponRule'); + $this->collCouponRules = new ObjectCollection(); + $this->collCouponRules->setModel('\Thelia\Model\CouponRule'); } /** - * Gets an array of CouponRule objects which contain a foreign key that references this object. + * Gets an array of ChildCouponRule objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCoupon is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCouponRule[] List of ChildCouponRule objects * @throws PropelException */ - public function getCouponRules($criteria = null, PropelPDO $con = null) + public function getCouponRules($criteria = null, ConnectionInterface $con = null) { $partial = $this->collCouponRulesPartial && !$this->isNew(); if (null === $this->collCouponRules || null !== $criteria || $partial) { @@ -1499,29 +1599,31 @@ abstract class BaseCoupon extends BaseObject implements Persistent // return empty collection $this->initCouponRules(); } else { - $collCouponRules = CouponRuleQuery::create(null, $criteria) + $collCouponRules = ChildCouponRuleQuery::create(null, $criteria) ->filterByCoupon($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collCouponRulesPartial && count($collCouponRules)) { - $this->initCouponRules(false); + $this->initCouponRules(false); - foreach($collCouponRules as $obj) { - if (false == $this->collCouponRules->contains($obj)) { - $this->collCouponRules->append($obj); + foreach ($collCouponRules as $obj) { + if (false == $this->collCouponRules->contains($obj)) { + $this->collCouponRules->append($obj); + } } - } - $this->collCouponRulesPartial = true; + $this->collCouponRulesPartial = true; } $collCouponRules->getInternalIterator()->rewind(); + return $collCouponRules; } - if($partial && $this->collCouponRules) { - foreach($this->collCouponRules as $obj) { - if($obj->isNew()) { + if ($partial && $this->collCouponRules) { + foreach ($this->collCouponRules as $obj) { + if ($obj->isNew()) { $collCouponRules[] = $obj; } } @@ -1541,15 +1643,16 @@ abstract class BaseCoupon extends BaseObject implements Persistent * It will 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) + * @param Collection $couponRules A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCoupon The current object (for fluent API support) */ - public function setCouponRules(PropelCollection $couponRules, PropelPDO $con = null) + public function setCouponRules(Collection $couponRules, ConnectionInterface $con = null) { $couponRulesToDelete = $this->getCouponRules(new Criteria(), $con)->diff($couponRules); - $this->couponRulesScheduledForDeletion = unserialize(serialize($couponRulesToDelete)); + + $this->couponRulesScheduledForDeletion = $couponRulesToDelete; foreach ($couponRulesToDelete as $couponRuleRemoved) { $couponRuleRemoved->setCoupon(null); @@ -1569,13 +1672,13 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * Returns the number of related CouponRule objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related CouponRule objects. * @throws PropelException */ - public function countCouponRules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countCouponRules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collCouponRulesPartial && !$this->isNew(); if (null === $this->collCouponRules || null !== $criteria || $partial) { @@ -1583,10 +1686,11 @@ abstract class BaseCoupon extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getCouponRules()); } - $query = CouponRuleQuery::create(null, $criteria); + + $query = ChildCouponRuleQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1600,18 +1704,19 @@ abstract class BaseCoupon extends BaseObject implements Persistent } /** - * Method called to associate a CouponRule object to this object - * through the CouponRule foreign key attribute. + * Method called to associate a ChildCouponRule object to this object + * through the ChildCouponRule foreign key attribute. * - * @param CouponRule $l CouponRule - * @return Coupon The current object (for fluent API support) + * @param ChildCouponRule $l ChildCouponRule + * @return \Thelia\Model\Coupon The current object (for fluent API support) */ - public function addCouponRule(CouponRule $l) + public function addCouponRule(ChildCouponRule $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); } @@ -1620,7 +1725,7 @@ abstract class BaseCoupon extends BaseObject implements Persistent } /** - * @param CouponRule $couponRule The couponRule object to add. + * @param CouponRule $couponRule The couponRule object to add. */ protected function doAddCouponRule($couponRule) { @@ -1629,8 +1734,8 @@ abstract class BaseCoupon extends BaseObject implements Persistent } /** - * @param CouponRule $couponRule The couponRule object to remove. - * @return Coupon The current object (for fluent API support) + * @param CouponRule $couponRule The couponRule object to remove. + * @return ChildCoupon The current object (for fluent API support) */ public function removeCouponRule($couponRule) { @@ -1663,8 +1768,6 @@ abstract class BaseCoupon extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1676,47 +1779,34 @@ abstract class BaseCoupon extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collCouponRules) { foreach ($this->collCouponRules as $o) { $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) - if ($this->collCouponRules instanceof PropelCollection) { + if ($this->collCouponRules instanceof Collection) { $this->collCouponRules->clearIterator(); } $this->collCouponRules = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(CouponTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1724,13 +1814,131 @@ abstract class BaseCoupon extends BaseObject implements Persistent /** * 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) + * @return ChildCoupon The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = CouponPeer::UPDATED_AT; + $this->modifiedColumns[] = CouponTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/CouponOrder.php b/core/lib/Thelia/Model/Base/CouponOrder.php new file mode 100644 index 000000000..32ae68fde --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponOrder.php @@ -0,0 +1,1476 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CouponOrder instance. If + * obj is an instance of CouponOrder, delegates to + * equals(CouponOrder). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CouponOrder The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CouponOrder The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CouponOrderTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [order_id] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) + */ + public function setOrderId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->order_id !== $v) { + $this->order_id = $v; + $this->modifiedColumns[] = CouponOrderTableMap::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 \Thelia\Model\CouponOrder The current object (for fluent API support) + */ + public function setCode($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->code !== $v) { + $this->code = $v; + $this->modifiedColumns[] = CouponOrderTableMap::CODE; + } + + + return $this; + } // setCode() + + /** + * Set the value of [value] column. + * + * @param double $v new value + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) + */ + public function setValue($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = CouponOrderTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CouponOrderTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CouponOrderTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponOrderTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponOrderTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponOrderTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponOrderTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $this->value = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponOrderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponOrderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = CouponOrderTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CouponOrder object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(CouponOrderTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCouponOrderQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aOrder = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CouponOrder::setDeleted() + * @see CouponOrder::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCouponOrderQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CouponOrderTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CouponOrderTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CouponOrderTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponOrderTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CouponOrderTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CouponOrderTableMap::ORDER_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_ID'; + } + if ($this->isColumnModified(CouponOrderTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; + } + if ($this->isColumnModified(CouponOrderTableMap::VALUE)) { + $modifiedColumns[':p' . $index++] = 'VALUE'; + } + if ($this->isColumnModified(CouponOrderTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(CouponOrderTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponOrderTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()] = true; + $keys = CouponOrderTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponOrderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = CouponOrderTableMap::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(CouponOrderTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CouponOrderTableMap::ID)) $criteria->add(CouponOrderTableMap::ID, $this->id); + if ($this->isColumnModified(CouponOrderTableMap::ORDER_ID)) $criteria->add(CouponOrderTableMap::ORDER_ID, $this->order_id); + if ($this->isColumnModified(CouponOrderTableMap::CODE)) $criteria->add(CouponOrderTableMap::CODE, $this->code); + if ($this->isColumnModified(CouponOrderTableMap::VALUE)) $criteria->add(CouponOrderTableMap::VALUE, $this->value); + if ($this->isColumnModified(CouponOrderTableMap::CREATED_AT)) $criteria->add(CouponOrderTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) $criteria->add(CouponOrderTableMap::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(CouponOrderTableMap::DATABASE_NAME); + $criteria->add(CouponOrderTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildOrder object. + * + * @param ChildOrder $v + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) + * @throws PropelException + */ + public function setOrder(ChildOrder $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 ChildOrder object, it will not be re-added. + if ($v !== null) { + $v->addCouponOrder($this); + } + + + return $this; + } + + + /** + * Get the associated ChildOrder object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrder The associated ChildOrder object. + * @throws PropelException + */ + public function getOrder(ConnectionInterface $con = null) + { + if ($this->aOrder === null && ($this->order_id !== null)) { + $this->aOrder = ChildOrderQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aOrder = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CouponOrderTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildCouponOrder The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CouponOrderTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php b/core/lib/Thelia/Model/Base/CouponOrderQuery.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseCouponOrderQuery.php rename to core/lib/Thelia/Model/Base/CouponOrderQuery.php index 5a6f86656..6897f56dd --- a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php +++ b/core/lib/Thelia/Model/Base/CouponOrderQuery.php @@ -1,95 +1,95 @@ setModelAlias($modelAlias); } @@ -110,21 +110,21 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return CouponOrder|CouponOrder[]|mixed the result, formatted by the current formatter + * @return ChildCouponOrder|array|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 + if ((null !== ($obj = CouponOrderTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CouponOrderTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -136,46 +136,31 @@ abstract class BaseCouponOrderQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return CouponOrder A model object, or null if the key is not found - * @throws PropelException + * @return ChildCouponOrder A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `order_id`, `code`, `value`, `created_at`, `updated_at` FROM `coupon_order` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CouponOrder(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCouponOrder(); $obj->hydrate($row); - CouponOrderPeer::addInstanceToPool($obj, (string) $key); + CouponOrderTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -186,19 +171,19 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return CouponOrder|CouponOrder[]|mixed the result, formatted by the current formatter + * @return ChildCouponOrder|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -207,22 +192,22 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|CouponOrder[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -230,12 +215,12 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CouponOrderQuery The current query, for fluid interface + * @return ChildCouponOrderQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(CouponOrderPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(CouponOrderTableMap::ID, $key, Criteria::EQUAL); } /** @@ -243,12 +228,12 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CouponOrderQuery The current query, for fluid interface + * @return ChildCouponOrderQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(CouponOrderPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(CouponOrderTableMap::ID, $keys, Criteria::IN); } /** @@ -258,8 +243,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -268,18 +252,18 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * 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 + * @return ChildCouponOrderQuery 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); + $this->addUsingAlias(CouponOrderTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CouponOrderPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponOrderTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -290,7 +274,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponOrderPeer::ID, $id, $comparison); + return $this->addUsingAlias(CouponOrderTableMap::ID, $id, $comparison); } /** @@ -300,8 +284,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * $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 + * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12 * * * @see filterByOrder() @@ -312,18 +295,18 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * 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 + * @return ChildCouponOrderQuery 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); + $this->addUsingAlias(CouponOrderTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($orderId['max'])) { - $this->addUsingAlias(CouponOrderPeer::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponOrderTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -334,7 +317,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponOrderPeer::ORDER_ID, $orderId, $comparison); + return $this->addUsingAlias(CouponOrderTableMap::ORDER_ID, $orderId, $comparison); } /** @@ -350,7 +333,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * 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 + * @return ChildCouponOrderQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -363,7 +346,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponOrderPeer::CODE, $code, $comparison); + return $this->addUsingAlias(CouponOrderTableMap::CODE, $code, $comparison); } /** @@ -373,8 +356,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * $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 + * $query->filterByValue(array('min' => 12)); // WHERE value > 12 * * * @param mixed $value The value to use as filter. @@ -383,18 +365,18 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * 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 + * @return ChildCouponOrderQuery 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); + $this->addUsingAlias(CouponOrderTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($value['max'])) { - $this->addUsingAlias(CouponOrderPeer::VALUE, $value['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponOrderTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -405,7 +387,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponOrderPeer::VALUE, $value, $comparison); + return $this->addUsingAlias(CouponOrderTableMap::VALUE, $value, $comparison); } /** @@ -426,18 +408,18 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * 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 + * @return ChildCouponOrderQuery 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); + $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CouponOrderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -448,7 +430,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponOrderPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -469,18 +451,18 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * 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 + * @return ChildCouponOrderQuery 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); + $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -491,32 +473,31 @@ abstract class BaseCouponOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Order object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Order|ObjectCollection $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. + * @return ChildCouponOrderQuery The current query, for fluid interface */ public function filterByOrder($order, $comparison = null) { - if ($order instanceof Order) { + if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(CouponOrderPeer::ORDER_ID, $order->getId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { + ->addUsingAlias(CouponOrderTableMap::ORDER_ID, $order->getId(), $comparison); + } elseif ($order instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(CouponOrderPeer::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(CouponOrderTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); + throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); } } @@ -526,7 +507,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * @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 + * @return ChildCouponOrderQuery The current query, for fluid interface */ public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -555,7 +536,7 @@ abstract class BaseCouponOrderQuery extends ModelCriteria /** * Use the Order relation Order object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -573,19 +554,94 @@ abstract class BaseCouponOrderQuery extends ModelCriteria /** * Exclude object from result * - * @param CouponOrder $couponOrder Object to remove from the list of results + * @param ChildCouponOrder $couponOrder Object to remove from the list of results * - * @return CouponOrderQuery The current query, for fluid interface + * @return ChildCouponOrderQuery The current query, for fluid interface */ public function prune($couponOrder = null) { if ($couponOrder) { - $this->addUsingAlias(CouponOrderPeer::ID, $couponOrder->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(CouponOrderTableMap::ID, $couponOrder->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the coupon_order table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CouponOrderTableMap::clearInstancePool(); + CouponOrderTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCouponOrder or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCouponOrder object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CouponOrderTableMap::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(); + + + CouponOrderTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CouponOrderTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -593,31 +649,11 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return CouponOrderQuery The current query, for fluid interface + * @return ChildCouponOrderQuery 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); + return $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -625,30 +661,51 @@ abstract class BaseCouponOrderQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return CouponOrderQuery The current query, for fluid interface + * @return ChildCouponOrderQuery 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); + return $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CouponOrderTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CouponOrderTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return CouponOrderQuery The current query, for fluid interface + * @return ChildCouponOrderQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(CouponOrderPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(CouponOrderTableMap::CREATED_AT); } /** * Order by create date asc * - * @return CouponOrderQuery The current query, for fluid interface + * @return ChildCouponOrderQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(CouponOrderPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(CouponOrderTableMap::CREATED_AT); } -} + +} // CouponOrderQuery diff --git a/core/lib/Thelia/Model/om/BaseCouponQuery.php b/core/lib/Thelia/Model/Base/CouponQuery.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseCouponQuery.php rename to core/lib/Thelia/Model/Base/CouponQuery.php index 4780154be..23fdd2e4c --- a/core/lib/Thelia/Model/om/BaseCouponQuery.php +++ b/core/lib/Thelia/Model/Base/CouponQuery.php @@ -1,111 +1,111 @@ setModelAlias($modelAlias); } @@ -126,21 +126,21 @@ abstract class BaseCouponQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Coupon|Coupon[]|mixed the result, formatted by the current formatter + * @return ChildCoupon|array|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 + if ((null !== ($obj = CouponTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CouponTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -152,46 +152,31 @@ abstract class BaseCouponQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Coupon A model object, or null if the key is not found - * @throws PropelException + * @return ChildCoupon A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Coupon(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCoupon(); $obj->hydrate($row); - CouponPeer::addInstanceToPool($obj, (string) $key); + CouponTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -202,19 +187,19 @@ abstract class BaseCouponQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Coupon|Coupon[]|mixed the result, formatted by the current formatter + * @return ChildCoupon|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -223,22 +208,22 @@ abstract class BaseCouponQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Coupon[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -246,12 +231,12 @@ abstract class BaseCouponQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CouponQuery The current query, for fluid interface + * @return ChildCouponQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(CouponPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(CouponTableMap::ID, $key, Criteria::EQUAL); } /** @@ -259,12 +244,12 @@ abstract class BaseCouponQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CouponQuery The current query, for fluid interface + * @return ChildCouponQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(CouponPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(CouponTableMap::ID, $keys, Criteria::IN); } /** @@ -274,8 +259,7 @@ abstract class BaseCouponQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -284,18 +268,18 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery 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); + $this->addUsingAlias(CouponTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CouponPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -306,7 +290,7 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::ID, $id, $comparison); + return $this->addUsingAlias(CouponTableMap::ID, $id, $comparison); } /** @@ -322,7 +306,7 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -335,7 +319,7 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::CODE, $code, $comparison); + return $this->addUsingAlias(CouponTableMap::CODE, $code, $comparison); } /** @@ -351,7 +335,7 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery The current query, for fluid interface */ public function filterByAction($action = null, $comparison = null) { @@ -364,7 +348,7 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::ACTION, $action, $comparison); + return $this->addUsingAlias(CouponTableMap::ACTION, $action, $comparison); } /** @@ -374,8 +358,7 @@ abstract class BaseCouponQuery extends ModelCriteria * * $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 + * $query->filterByValue(array('min' => 12)); // WHERE value > 12 * * * @param mixed $value The value to use as filter. @@ -384,18 +367,18 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery 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); + $this->addUsingAlias(CouponTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($value['max'])) { - $this->addUsingAlias(CouponPeer::VALUE, $value['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -406,7 +389,7 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::VALUE, $value, $comparison); + return $this->addUsingAlias(CouponTableMap::VALUE, $value, $comparison); } /** @@ -416,8 +399,7 @@ abstract class BaseCouponQuery extends ModelCriteria * * $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 + * $query->filterByUsed(array('min' => 12)); // WHERE used > 12 * * * @param mixed $used The value to use as filter. @@ -426,18 +408,18 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery 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); + $this->addUsingAlias(CouponTableMap::USED, $used['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($used['max'])) { - $this->addUsingAlias(CouponPeer::USED, $used['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponTableMap::USED, $used['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -448,7 +430,7 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::USED, $used, $comparison); + return $this->addUsingAlias(CouponTableMap::USED, $used, $comparison); } /** @@ -469,18 +451,18 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery 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); + $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($availableSince['max'])) { - $this->addUsingAlias(CouponPeer::AVAILABLE_SINCE, $availableSince['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -491,7 +473,7 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::AVAILABLE_SINCE, $availableSince, $comparison); + return $this->addUsingAlias(CouponTableMap::AVAILABLE_SINCE, $availableSince, $comparison); } /** @@ -512,18 +494,18 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery 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); + $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($dateLimit['max'])) { - $this->addUsingAlias(CouponPeer::DATE_LIMIT, $dateLimit['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -534,7 +516,7 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::DATE_LIMIT, $dateLimit, $comparison); + return $this->addUsingAlias(CouponTableMap::DATE_LIMIT, $dateLimit, $comparison); } /** @@ -544,8 +526,7 @@ abstract class BaseCouponQuery extends ModelCriteria * * $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 + * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12 * * * @param mixed $activate The value to use as filter. @@ -554,18 +535,18 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery 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); + $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($activate['max'])) { - $this->addUsingAlias(CouponPeer::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -576,7 +557,7 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::ACTIVATE, $activate, $comparison); + return $this->addUsingAlias(CouponTableMap::ACTIVATE, $activate, $comparison); } /** @@ -597,18 +578,18 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery 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); + $this->addUsingAlias(CouponTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CouponPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -619,7 +600,7 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CouponTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -640,18 +621,18 @@ abstract class BaseCouponQuery extends ModelCriteria * 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 + * @return ChildCouponQuery 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); + $this->addUsingAlias(CouponTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CouponPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -662,30 +643,29 @@ abstract class BaseCouponQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CouponTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related CouponRule object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\CouponRule|ObjectCollection $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. + * @return ChildCouponQuery The current query, for fluid interface */ public function filterByCouponRule($couponRule, $comparison = null) { - if ($couponRule instanceof CouponRule) { + if ($couponRule instanceof \Thelia\Model\CouponRule) { return $this - ->addUsingAlias(CouponPeer::ID, $couponRule->getCouponId(), $comparison); - } elseif ($couponRule instanceof PropelObjectCollection) { + ->addUsingAlias(CouponTableMap::ID, $couponRule->getCouponId(), $comparison); + } elseif ($couponRule instanceof ObjectCollection) { return $this ->useCouponRuleQuery() ->filterByPrimaryKeys($couponRule->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCouponRule() only accepts arguments of type CouponRule or PropelCollection'); + throw new PropelException('filterByCouponRule() only accepts arguments of type \Thelia\Model\CouponRule or Collection'); } } @@ -695,7 +675,7 @@ abstract class BaseCouponQuery extends ModelCriteria * @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 + * @return ChildCouponQuery The current query, for fluid interface */ public function joinCouponRule($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -724,7 +704,7 @@ abstract class BaseCouponQuery extends ModelCriteria /** * Use the CouponRule relation CouponRule object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -742,19 +722,94 @@ abstract class BaseCouponQuery extends ModelCriteria /** * Exclude object from result * - * @param Coupon $coupon Object to remove from the list of results + * @param ChildCoupon $coupon Object to remove from the list of results * - * @return CouponQuery The current query, for fluid interface + * @return ChildCouponQuery The current query, for fluid interface */ public function prune($coupon = null) { if ($coupon) { - $this->addUsingAlias(CouponPeer::ID, $coupon->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(CouponTableMap::ID, $coupon->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the coupon table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CouponTableMap::clearInstancePool(); + CouponTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCoupon or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCoupon object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CouponTableMap::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(); + + + CouponTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CouponTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -762,31 +817,11 @@ abstract class BaseCouponQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return CouponQuery The current query, for fluid interface + * @return ChildCouponQuery 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); + return $this->addUsingAlias(CouponTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -794,30 +829,51 @@ abstract class BaseCouponQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return CouponQuery The current query, for fluid interface + * @return ChildCouponQuery 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); + return $this->addUsingAlias(CouponTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CouponTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCouponQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CouponTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return CouponQuery The current query, for fluid interface + * @return ChildCouponQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(CouponPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(CouponTableMap::CREATED_AT); } /** * Order by create date asc * - * @return CouponQuery The current query, for fluid interface + * @return ChildCouponQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(CouponPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(CouponTableMap::CREATED_AT); } -} + +} // CouponQuery diff --git a/core/lib/Thelia/Model/Base/CouponRule.php b/core/lib/Thelia/Model/Base/CouponRule.php new file mode 100644 index 000000000..5602b0044 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponRule.php @@ -0,0 +1,1534 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CouponRule instance. If + * obj is an instance of CouponRule, delegates to + * equals(CouponRule). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CouponRule The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CouponRule The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponRule The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CouponRuleTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [coupon_id] column. + * + * @param int $v new value + * @return \Thelia\Model\CouponRule The current object (for fluent API support) + */ + public function setCouponId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->coupon_id !== $v) { + $this->coupon_id = $v; + $this->modifiedColumns[] = CouponRuleTableMap::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 \Thelia\Model\CouponRule The current object (for fluent API support) + */ + public function setController($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->controller !== $v) { + $this->controller = $v; + $this->modifiedColumns[] = CouponRuleTableMap::CONTROLLER; + } + + + return $this; + } // setController() + + /** + * Set the value of [operation] column. + * + * @param string $v new value + * @return \Thelia\Model\CouponRule The current object (for fluent API support) + */ + public function setOperation($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->operation !== $v) { + $this->operation = $v; + $this->modifiedColumns[] = CouponRuleTableMap::OPERATION; + } + + + return $this; + } // setOperation() + + /** + * Set the value of [value] column. + * + * @param double $v new value + * @return \Thelia\Model\CouponRule The current object (for fluent API support) + */ + public function setValue($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = CouponRuleTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CouponRuleTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CouponRuleTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponRuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponRuleTableMap::translateFieldName('CouponId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->coupon_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponRuleTableMap::translateFieldName('Controller', TableMap::TYPE_PHPNAME, $indexType)]; + $this->controller = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponRuleTableMap::translateFieldName('Operation', TableMap::TYPE_PHPNAME, $indexType)]; + $this->operation = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponRuleTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $this->value = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CouponRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CouponRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = CouponRuleTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CouponRule object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(CouponRuleTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCouponRuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCoupon = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CouponRule::setDeleted() + * @see CouponRule::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCouponRuleQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(CouponRuleTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(CouponRuleTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(CouponRuleTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + CouponRuleTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = CouponRuleTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponRuleTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CouponRuleTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CouponRuleTableMap::COUPON_ID)) { + $modifiedColumns[':p' . $index++] = 'COUPON_ID'; + } + if ($this->isColumnModified(CouponRuleTableMap::CONTROLLER)) { + $modifiedColumns[':p' . $index++] = 'CONTROLLER'; + } + if ($this->isColumnModified(CouponRuleTableMap::OPERATION)) { + $modifiedColumns[':p' . $index++] = 'OPERATION'; + } + if ($this->isColumnModified(CouponRuleTableMap::VALUE)) { + $modifiedColumns[':p' . $index++] = 'VALUE'; + } + if ($this->isColumnModified(CouponRuleTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(CouponRuleTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponRuleTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CouponRule'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CouponRule'][$this->getPrimaryKey()] = true; + $keys = CouponRuleTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CouponRuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = CouponRuleTableMap::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(CouponRuleTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CouponRuleTableMap::ID)) $criteria->add(CouponRuleTableMap::ID, $this->id); + if ($this->isColumnModified(CouponRuleTableMap::COUPON_ID)) $criteria->add(CouponRuleTableMap::COUPON_ID, $this->coupon_id); + if ($this->isColumnModified(CouponRuleTableMap::CONTROLLER)) $criteria->add(CouponRuleTableMap::CONTROLLER, $this->controller); + if ($this->isColumnModified(CouponRuleTableMap::OPERATION)) $criteria->add(CouponRuleTableMap::OPERATION, $this->operation); + if ($this->isColumnModified(CouponRuleTableMap::VALUE)) $criteria->add(CouponRuleTableMap::VALUE, $this->value); + if ($this->isColumnModified(CouponRuleTableMap::CREATED_AT)) $criteria->add(CouponRuleTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CouponRuleTableMap::UPDATED_AT)) $criteria->add(CouponRuleTableMap::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(CouponRuleTableMap::DATABASE_NAME); + $criteria->add(CouponRuleTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildCoupon object. + * + * @param ChildCoupon $v + * @return \Thelia\Model\CouponRule The current object (for fluent API support) + * @throws PropelException + */ + public function setCoupon(ChildCoupon $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 ChildCoupon object, it will not be re-added. + if ($v !== null) { + $v->addCouponRule($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCoupon object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCoupon The associated ChildCoupon object. + * @throws PropelException + */ + public function getCoupon(ConnectionInterface $con = null) + { + if ($this->aCoupon === null && ($this->coupon_id !== null)) { + $this->aCoupon = ChildCouponQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCoupon = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CouponRuleTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildCouponRule The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = CouponRuleTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php b/core/lib/Thelia/Model/Base/CouponRuleQuery.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseCouponRuleQuery.php rename to core/lib/Thelia/Model/Base/CouponRuleQuery.php index f1cfc175c..0789f84d6 --- a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php +++ b/core/lib/Thelia/Model/Base/CouponRuleQuery.php @@ -1,99 +1,99 @@ setModelAlias($modelAlias); } @@ -114,21 +114,21 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return CouponRule|CouponRule[]|mixed the result, formatted by the current formatter + * @return ChildCouponRule|array|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 + if ((null !== ($obj = CouponRuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CouponRuleTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -140,46 +140,31 @@ abstract class BaseCouponRuleQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return CouponRule A model object, or null if the key is not found - * @throws PropelException + * @return ChildCouponRule A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `coupon_id`, `controller`, `operation`, `value`, `created_at`, `updated_at` FROM `coupon_rule` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CouponRule(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCouponRule(); $obj->hydrate($row); - CouponRulePeer::addInstanceToPool($obj, (string) $key); + CouponRuleTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -190,19 +175,19 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return CouponRule|CouponRule[]|mixed the result, formatted by the current formatter + * @return ChildCouponRule|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -211,22 +196,22 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|CouponRule[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -234,12 +219,12 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CouponRuleQuery The current query, for fluid interface + * @return ChildCouponRuleQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(CouponRulePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(CouponRuleTableMap::ID, $key, Criteria::EQUAL); } /** @@ -247,12 +232,12 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CouponRuleQuery The current query, for fluid interface + * @return ChildCouponRuleQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(CouponRulePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(CouponRuleTableMap::ID, $keys, Criteria::IN); } /** @@ -262,8 +247,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -272,18 +256,18 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * 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 + * @return ChildCouponRuleQuery 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); + $this->addUsingAlias(CouponRuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CouponRulePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponRuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -294,7 +278,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponRulePeer::ID, $id, $comparison); + return $this->addUsingAlias(CouponRuleTableMap::ID, $id, $comparison); } /** @@ -304,8 +288,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * $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 + * $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id > 12 * * * @see filterByCoupon() @@ -316,18 +299,18 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * 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 + * @return ChildCouponRuleQuery 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); + $this->addUsingAlias(CouponRuleTableMap::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($couponId['max'])) { - $this->addUsingAlias(CouponRulePeer::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponRuleTableMap::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -338,7 +321,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponRulePeer::COUPON_ID, $couponId, $comparison); + return $this->addUsingAlias(CouponRuleTableMap::COUPON_ID, $couponId, $comparison); } /** @@ -354,7 +337,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * 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 + * @return ChildCouponRuleQuery The current query, for fluid interface */ public function filterByController($controller = null, $comparison = null) { @@ -367,7 +350,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponRulePeer::CONTROLLER, $controller, $comparison); + return $this->addUsingAlias(CouponRuleTableMap::CONTROLLER, $controller, $comparison); } /** @@ -383,7 +366,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * 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 + * @return ChildCouponRuleQuery The current query, for fluid interface */ public function filterByOperation($operation = null, $comparison = null) { @@ -396,7 +379,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponRulePeer::OPERATION, $operation, $comparison); + return $this->addUsingAlias(CouponRuleTableMap::OPERATION, $operation, $comparison); } /** @@ -406,8 +389,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * $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 + * $query->filterByValue(array('min' => 12)); // WHERE value > 12 * * * @param mixed $value The value to use as filter. @@ -416,18 +398,18 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * 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 + * @return ChildCouponRuleQuery 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); + $this->addUsingAlias(CouponRuleTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($value['max'])) { - $this->addUsingAlias(CouponRulePeer::VALUE, $value['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponRuleTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -438,7 +420,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponRulePeer::VALUE, $value, $comparison); + return $this->addUsingAlias(CouponRuleTableMap::VALUE, $value, $comparison); } /** @@ -459,18 +441,18 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * 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 + * @return ChildCouponRuleQuery 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); + $this->addUsingAlias(CouponRuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CouponRulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponRuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -481,7 +463,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponRulePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CouponRuleTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -502,18 +484,18 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * 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 + * @return ChildCouponRuleQuery 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); + $this->addUsingAlias(CouponRuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CouponRulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CouponRuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -524,32 +506,31 @@ abstract class BaseCouponRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(CouponRulePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CouponRuleTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Coupon object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Coupon|ObjectCollection $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. + * @return ChildCouponRuleQuery The current query, for fluid interface */ public function filterByCoupon($coupon, $comparison = null) { - if ($coupon instanceof Coupon) { + if ($coupon instanceof \Thelia\Model\Coupon) { return $this - ->addUsingAlias(CouponRulePeer::COUPON_ID, $coupon->getId(), $comparison); - } elseif ($coupon instanceof PropelObjectCollection) { + ->addUsingAlias(CouponRuleTableMap::COUPON_ID, $coupon->getId(), $comparison); + } elseif ($coupon instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(CouponRulePeer::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(CouponRuleTableMap::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCoupon() only accepts arguments of type Coupon or PropelCollection'); + throw new PropelException('filterByCoupon() only accepts arguments of type \Thelia\Model\Coupon or Collection'); } } @@ -559,7 +540,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * @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 + * @return ChildCouponRuleQuery The current query, for fluid interface */ public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -588,7 +569,7 @@ abstract class BaseCouponRuleQuery extends ModelCriteria /** * Use the Coupon relation Coupon object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -606,19 +587,94 @@ abstract class BaseCouponRuleQuery extends ModelCriteria /** * Exclude object from result * - * @param CouponRule $couponRule Object to remove from the list of results + * @param ChildCouponRule $couponRule Object to remove from the list of results * - * @return CouponRuleQuery The current query, for fluid interface + * @return ChildCouponRuleQuery The current query, for fluid interface */ public function prune($couponRule = null) { if ($couponRule) { - $this->addUsingAlias(CouponRulePeer::ID, $couponRule->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(CouponRuleTableMap::ID, $couponRule->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the coupon_rule table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CouponRuleTableMap::clearInstancePool(); + CouponRuleTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCouponRule or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCouponRule object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CouponRuleTableMap::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(); + + + CouponRuleTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CouponRuleTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -626,31 +682,11 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return CouponRuleQuery The current query, for fluid interface + * @return ChildCouponRuleQuery 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); + return $this->addUsingAlias(CouponRuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -658,30 +694,51 @@ abstract class BaseCouponRuleQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return CouponRuleQuery The current query, for fluid interface + * @return ChildCouponRuleQuery 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); + return $this->addUsingAlias(CouponRuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCouponRuleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CouponRuleTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCouponRuleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CouponRuleTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return CouponRuleQuery The current query, for fluid interface + * @return ChildCouponRuleQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(CouponRulePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(CouponRuleTableMap::CREATED_AT); } /** * Order by create date asc * - * @return CouponRuleQuery The current query, for fluid interface + * @return ChildCouponRuleQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(CouponRulePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(CouponRuleTableMap::CREATED_AT); } -} + +} // CouponRuleQuery diff --git a/core/lib/Thelia/Model/om/BaseCurrency.php b/core/lib/Thelia/Model/Base/Currency.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseCurrency.php rename to core/lib/Thelia/Model/Base/Currency.php index 137e18da3..5edf0b8e1 --- a/core/lib/Thelia/Model/om/BaseCurrency.php +++ b/core/lib/Thelia/Model/Base/Currency.php @@ -1,53 +1,61 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Currency instance. If + * obj is an instance of Currency, delegates to + * equals(Currency). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Currency The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Currency The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [name] column value. * - * @return string + * @return string */ public function getName() { + return $this->name; } /** * Get the [code] column value. * - * @return string + * @return string */ public function getCode() { + return $this->code; } /** * Get the [symbol] column value. * - * @return string + * @return string */ public function getSymbol() { + return $this->symbol; } /** * Get the [rate] column value. * - * @return double + * @return double */ public function getRate() { + return $this->rate; } /** * Get the [by_default] column value. * - * @return int + * @return int */ public function getByDefault() { + return $this->by_default; } @@ -193,97 +449,57 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Currency The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = CurrencyPeer::ID; + $this->modifiedColumns[] = CurrencyTableMap::ID; } @@ -293,18 +509,18 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Set the value of [name] column. * - * @param string $v new value - * @return Currency The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Currency The current object (for fluent API support) */ public function setName($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->name !== $v) { $this->name = $v; - $this->modifiedColumns[] = CurrencyPeer::NAME; + $this->modifiedColumns[] = CurrencyTableMap::NAME; } @@ -314,18 +530,18 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Set the value of [code] column. * - * @param string $v new value - * @return Currency The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Currency The current object (for fluent API support) */ public function setCode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->code !== $v) { $this->code = $v; - $this->modifiedColumns[] = CurrencyPeer::CODE; + $this->modifiedColumns[] = CurrencyTableMap::CODE; } @@ -335,18 +551,18 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Set the value of [symbol] column. * - * @param string $v new value - * @return Currency The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Currency The current object (for fluent API support) */ public function setSymbol($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->symbol !== $v) { $this->symbol = $v; - $this->modifiedColumns[] = CurrencyPeer::SYMBOL; + $this->modifiedColumns[] = CurrencyTableMap::SYMBOL; } @@ -356,18 +572,18 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Set the value of [rate] column. * - * @param double $v new value - * @return Currency The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\Currency The current object (for fluent API support) */ public function setRate($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->rate !== $v) { $this->rate = $v; - $this->modifiedColumns[] = CurrencyPeer::RATE; + $this->modifiedColumns[] = CurrencyTableMap::RATE; } @@ -377,18 +593,18 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Set the value of [by_default] column. * - * @param int $v new value - * @return Currency The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Currency The current object (for fluent API support) */ public function setByDefault($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->by_default !== $v) { $this->by_default = $v; - $this->modifiedColumns[] = CurrencyPeer::BY_DEFAULT; + $this->modifiedColumns[] = CurrencyTableMap::BY_DEFAULT; } @@ -398,19 +614,17 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Currency The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CurrencyTableMap::CREATED_AT; } } // if either are not null @@ -421,19 +635,17 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Currency The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CurrencyTableMap::UPDATED_AT; } } // if either are not null @@ -451,7 +663,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -463,24 +675,50 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CurrencyTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CurrencyTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; + $this->name = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CurrencyTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CurrencyTableMap::translateFieldName('Symbol', TableMap::TYPE_PHPNAME, $indexType)]; + $this->symbol = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CurrencyTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)]; + $this->rate = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CurrencyTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->by_default = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CurrencyTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CurrencyTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -488,11 +726,11 @@ abstract class BaseCurrency extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = CurrencyPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 8; // 8 = CurrencyTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Currency object", $e); + throw new PropelException("Error populating \Thelia\Model\Currency object", 0, $e); } } @@ -511,7 +749,6 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -519,12 +756,12 @@ abstract class BaseCurrency extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -535,19 +772,19 @@ abstract class BaseCurrency extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CurrencyTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildCurrencyQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -559,26 +796,25 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Currency::setDeleted() + * @see Currency::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = CurrencyQuery::create() + $deleteQuery = ChildCurrencyQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -603,20 +839,19 @@ abstract class BaseCurrency extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -626,16 +861,16 @@ abstract class BaseCurrency extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(CurrencyPeer::CREATED_AT)) { + if (!$this->isColumnModified(CurrencyTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(CurrencyPeer::UPDATED_AT)) { + if (!$this->isColumnModified(CurrencyTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CurrencyPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(CurrencyTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -647,7 +882,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - CurrencyPeer::addInstanceToPool($this); + CurrencyTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -666,12 +901,12 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -698,8 +933,8 @@ abstract class BaseCurrency extends BaseObject implements Persistent } } - if ($this->collOrders !== null) { - foreach ($this->collOrders as $referrerFK) { + if ($this->collOrders !== null) { + foreach ($this->collOrders as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -716,49 +951,49 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = CurrencyPeer::ID; + $this->modifiedColumns[] = CurrencyTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CurrencyPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CurrencyTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CurrencyPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(CurrencyTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(CurrencyPeer::NAME)) { - $modifiedColumns[':p' . $index++] = '`name`'; + if ($this->isColumnModified(CurrencyTableMap::NAME)) { + $modifiedColumns[':p' . $index++] = 'NAME'; } - if ($this->isColumnModified(CurrencyPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; + if ($this->isColumnModified(CurrencyTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(CurrencyPeer::SYMBOL)) { - $modifiedColumns[':p' . $index++] = '`symbol`'; + if ($this->isColumnModified(CurrencyTableMap::SYMBOL)) { + $modifiedColumns[':p' . $index++] = 'SYMBOL'; } - if ($this->isColumnModified(CurrencyPeer::RATE)) { - $modifiedColumns[':p' . $index++] = '`rate`'; + if ($this->isColumnModified(CurrencyTableMap::RATE)) { + $modifiedColumns[':p' . $index++] = 'RATE'; } - if ($this->isColumnModified(CurrencyPeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`by_default`'; + if ($this->isColumnModified(CurrencyTableMap::BY_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'BY_DEFAULT'; } - if ($this->isColumnModified(CurrencyPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(CurrencyTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(CurrencyPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(CurrencyTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `currency` (%s) VALUES (%s)', + 'INSERT INTO currency (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -767,42 +1002,42 @@ abstract class BaseCurrency extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`name`': + case 'NAME': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; - case '`code`': + case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`symbol`': + case 'SYMBOL': $stmt->bindValue($identifier, $this->symbol, PDO::PARAM_STR); break; - case '`rate`': + case 'RATE': $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR); break; - case '`by_default`': + 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); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -812,112 +1047,32 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = CurrencyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CurrencyTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -927,7 +1082,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -969,22 +1124,22 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = CurrencyTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getName(), @@ -995,6 +1150,12 @@ abstract class BaseCurrency extends BaseObject implements Persistent $keys[6] => $this->getCreatedAt(), $keys[7] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collOrders) { $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1007,27 +1168,27 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = CurrencyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CurrencyTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1069,17 +1230,17 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = CurrencyPeer::getFieldNames($keyType); + $keys = CurrencyTableMap::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]]); @@ -1098,16 +1259,16 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(CurrencyPeer::DATABASE_NAME); + $criteria = new Criteria(CurrencyTableMap::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); + if ($this->isColumnModified(CurrencyTableMap::ID)) $criteria->add(CurrencyTableMap::ID, $this->id); + if ($this->isColumnModified(CurrencyTableMap::NAME)) $criteria->add(CurrencyTableMap::NAME, $this->name); + if ($this->isColumnModified(CurrencyTableMap::CODE)) $criteria->add(CurrencyTableMap::CODE, $this->code); + if ($this->isColumnModified(CurrencyTableMap::SYMBOL)) $criteria->add(CurrencyTableMap::SYMBOL, $this->symbol); + if ($this->isColumnModified(CurrencyTableMap::RATE)) $criteria->add(CurrencyTableMap::RATE, $this->rate); + if ($this->isColumnModified(CurrencyTableMap::BY_DEFAULT)) $criteria->add(CurrencyTableMap::BY_DEFAULT, $this->by_default); + if ($this->isColumnModified(CurrencyTableMap::CREATED_AT)) $criteria->add(CurrencyTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CurrencyTableMap::UPDATED_AT)) $criteria->add(CurrencyTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1122,15 +1283,15 @@ abstract class BaseCurrency extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(CurrencyPeer::DATABASE_NAME); - $criteria->add(CurrencyPeer::ID, $this->id); + $criteria = new Criteria(CurrencyTableMap::DATABASE_NAME); + $criteria->add(CurrencyTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1140,7 +1301,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1164,9 +1325,9 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1179,12 +1340,10 @@ abstract class BaseCurrency extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1192,8 +1351,6 @@ abstract class BaseCurrency extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1210,8 +1367,8 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Currency Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1224,37 +1381,19 @@ abstract class BaseCurrency extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('Order' == $relationName) { - $this->initOrders(); + return $this->initOrders(); } } @@ -1264,21 +1403,16 @@ abstract class BaseCurrency extends BaseObject implements Persistent * This 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) + * @return void * @see addOrders() */ public function clearOrders() { - $this->collOrders = null; // important to set this to null since that means it is uninitialized - $this->collOrdersPartial = null; - - return $this; + $this->collOrders = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collOrders collection loaded partially - * - * @return void + * Reset is the collOrders collection loaded partially. */ public function resetPartialOrders($v = true) { @@ -1292,7 +1426,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1302,25 +1436,25 @@ abstract class BaseCurrency extends BaseObject implements Persistent if (null !== $this->collOrders && !$overrideExisting) { return; } - $this->collOrders = new PropelObjectCollection(); - $this->collOrders->setModel('Order'); + $this->collOrders = new ObjectCollection(); + $this->collOrders->setModel('\Thelia\Model\Order'); } /** - * Gets an array of Order objects which contain a foreign key that references this object. + * Gets an array of ChildOrder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCurrency is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects * @throws PropelException */ - public function getOrders($criteria = null, PropelPDO $con = null) + public function getOrders($criteria = null, ConnectionInterface $con = null) { $partial = $this->collOrdersPartial && !$this->isNew(); if (null === $this->collOrders || null !== $criteria || $partial) { @@ -1328,29 +1462,31 @@ abstract class BaseCurrency extends BaseObject implements Persistent // return empty collection $this->initOrders(); } else { - $collOrders = OrderQuery::create(null, $criteria) + $collOrders = ChildOrderQuery::create(null, $criteria) ->filterByCurrency($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collOrdersPartial && count($collOrders)) { - $this->initOrders(false); + $this->initOrders(false); - foreach($collOrders as $obj) { - if (false == $this->collOrders->contains($obj)) { - $this->collOrders->append($obj); + foreach ($collOrders as $obj) { + if (false == $this->collOrders->contains($obj)) { + $this->collOrders->append($obj); + } } - } - $this->collOrdersPartial = true; + $this->collOrdersPartial = true; } $collOrders->getInternalIterator()->rewind(); + return $collOrders; } - if($partial && $this->collOrders) { - foreach($this->collOrders as $obj) { - if($obj->isNew()) { + if ($partial && $this->collOrders) { + foreach ($this->collOrders as $obj) { + if ($obj->isNew()) { $collOrders[] = $obj; } } @@ -1370,15 +1506,16 @@ abstract class BaseCurrency extends BaseObject implements Persistent * It will 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) + * @param Collection $orders A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCurrency The current object (for fluent API support) */ - public function setOrders(PropelCollection $orders, PropelPDO $con = null) + public function setOrders(Collection $orders, ConnectionInterface $con = null) { $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); - $this->ordersScheduledForDeletion = unserialize(serialize($ordersToDelete)); + + $this->ordersScheduledForDeletion = $ordersToDelete; foreach ($ordersToDelete as $orderRemoved) { $orderRemoved->setCurrency(null); @@ -1398,13 +1535,13 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * Returns the number of related Order objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Order objects. * @throws PropelException */ - public function countOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collOrdersPartial && !$this->isNew(); if (null === $this->collOrders || null !== $criteria || $partial) { @@ -1412,10 +1549,11 @@ abstract class BaseCurrency extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getOrders()); } - $query = OrderQuery::create(null, $criteria); + + $query = ChildOrderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1429,18 +1567,19 @@ abstract class BaseCurrency extends BaseObject implements Persistent } /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. * - * @param Order $l Order - * @return Currency The current object (for fluent API support) + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\Currency The current object (for fluent API support) */ - public function addOrder(Order $l) + public function addOrder(ChildOrder $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); } @@ -1449,7 +1588,7 @@ abstract class BaseCurrency extends BaseObject implements Persistent } /** - * @param Order $order The order object to add. + * @param Order $order The order object to add. */ protected function doAddOrder($order) { @@ -1458,8 +1597,8 @@ abstract class BaseCurrency extends BaseObject implements Persistent } /** - * @param Order $order The order object to remove. - * @return Currency The current object (for fluent API support) + * @param Order $order The order object to remove. + * @return ChildCurrency The current object (for fluent API support) */ public function removeOrder($order) { @@ -1488,15 +1627,15 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); return $this->getOrders($query, $con); } @@ -1513,15 +1652,15 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior); return $this->getOrders($query, $con); } @@ -1538,15 +1677,15 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior); return $this->getOrders($query, $con); } @@ -1563,15 +1702,15 @@ abstract class BaseCurrency extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderStatus', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); return $this->getOrders($query, $con); } @@ -1590,8 +1729,6 @@ abstract class BaseCurrency extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1603,47 +1740,34 @@ abstract class BaseCurrency extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collOrders) { foreach ($this->collOrders as $o) { $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) - if ($this->collOrders instanceof PropelCollection) { + if ($this->collOrders instanceof Collection) { $this->collOrders->clearIterator(); } $this->collOrders = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(CurrencyTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1651,13 +1775,131 @@ abstract class BaseCurrency extends BaseObject implements Persistent /** * 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) + * @return ChildCurrency The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = CurrencyPeer::UPDATED_AT; + $this->modifiedColumns[] = CurrencyTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php b/core/lib/Thelia/Model/Base/CurrencyQuery.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseCurrencyQuery.php rename to core/lib/Thelia/Model/Base/CurrencyQuery.php index 7c202ec84..6bc45c3d7 --- a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php +++ b/core/lib/Thelia/Model/Base/CurrencyQuery.php @@ -1,103 +1,103 @@ setModelAlias($modelAlias); } @@ -118,21 +118,21 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Currency|Currency[]|mixed the result, formatted by the current formatter + * @return ChildCurrency|array|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 + if ((null !== ($obj = CurrencyTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CurrencyTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -144,46 +144,31 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Currency A model object, or null if the key is not found - * @throws PropelException + * @return ChildCurrency A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `name`, `code`, `symbol`, `rate`, `by_default`, `created_at`, `updated_at` FROM `currency` WHERE `id` = :p0'; + $sql = 'SELECT ID, NAME, CODE, SYMBOL, RATE, BY_DEFAULT, CREATED_AT, UPDATED_AT FROM currency WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Currency(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCurrency(); $obj->hydrate($row); - CurrencyPeer::addInstanceToPool($obj, (string) $key); + CurrencyTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -194,19 +179,19 @@ abstract class BaseCurrencyQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Currency|Currency[]|mixed the result, formatted by the current formatter + * @return ChildCurrency|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -215,22 +200,22 @@ abstract class BaseCurrencyQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Currency[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -238,12 +223,12 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CurrencyQuery The current query, for fluid interface + * @return ChildCurrencyQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(CurrencyPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(CurrencyTableMap::ID, $key, Criteria::EQUAL); } /** @@ -251,12 +236,12 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CurrencyQuery The current query, for fluid interface + * @return ChildCurrencyQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(CurrencyPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(CurrencyTableMap::ID, $keys, Criteria::IN); } /** @@ -266,8 +251,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -276,18 +260,18 @@ abstract class BaseCurrencyQuery extends ModelCriteria * 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 + * @return ChildCurrencyQuery 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); + $this->addUsingAlias(CurrencyTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CurrencyPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CurrencyTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -298,7 +282,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - return $this->addUsingAlias(CurrencyPeer::ID, $id, $comparison); + return $this->addUsingAlias(CurrencyTableMap::ID, $id, $comparison); } /** @@ -314,7 +298,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria * 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 + * @return ChildCurrencyQuery The current query, for fluid interface */ public function filterByName($name = null, $comparison = null) { @@ -327,7 +311,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - return $this->addUsingAlias(CurrencyPeer::NAME, $name, $comparison); + return $this->addUsingAlias(CurrencyTableMap::NAME, $name, $comparison); } /** @@ -343,7 +327,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria * 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 + * @return ChildCurrencyQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -356,7 +340,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - return $this->addUsingAlias(CurrencyPeer::CODE, $code, $comparison); + return $this->addUsingAlias(CurrencyTableMap::CODE, $code, $comparison); } /** @@ -372,7 +356,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria * 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 + * @return ChildCurrencyQuery The current query, for fluid interface */ public function filterBySymbol($symbol = null, $comparison = null) { @@ -385,7 +369,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - return $this->addUsingAlias(CurrencyPeer::SYMBOL, $symbol, $comparison); + return $this->addUsingAlias(CurrencyTableMap::SYMBOL, $symbol, $comparison); } /** @@ -395,8 +379,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * $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 + * $query->filterByRate(array('min' => 12)); // WHERE rate > 12 * * * @param mixed $rate The value to use as filter. @@ -405,18 +388,18 @@ abstract class BaseCurrencyQuery extends ModelCriteria * 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 + * @return ChildCurrencyQuery 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); + $this->addUsingAlias(CurrencyTableMap::RATE, $rate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($rate['max'])) { - $this->addUsingAlias(CurrencyPeer::RATE, $rate['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CurrencyTableMap::RATE, $rate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -427,7 +410,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - return $this->addUsingAlias(CurrencyPeer::RATE, $rate, $comparison); + return $this->addUsingAlias(CurrencyTableMap::RATE, $rate, $comparison); } /** @@ -437,8 +420,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * $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 + * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12 * * * @param mixed $byDefault The value to use as filter. @@ -447,18 +429,18 @@ abstract class BaseCurrencyQuery extends ModelCriteria * 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 + * @return ChildCurrencyQuery 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); + $this->addUsingAlias(CurrencyTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($byDefault['max'])) { - $this->addUsingAlias(CurrencyPeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CurrencyTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -469,7 +451,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - return $this->addUsingAlias(CurrencyPeer::BY_DEFAULT, $byDefault, $comparison); + return $this->addUsingAlias(CurrencyTableMap::BY_DEFAULT, $byDefault, $comparison); } /** @@ -490,18 +472,18 @@ abstract class BaseCurrencyQuery extends ModelCriteria * 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 + * @return ChildCurrencyQuery 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); + $this->addUsingAlias(CurrencyTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CurrencyPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CurrencyTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -512,7 +494,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - return $this->addUsingAlias(CurrencyPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CurrencyTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -533,18 +515,18 @@ abstract class BaseCurrencyQuery extends ModelCriteria * 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 + * @return ChildCurrencyQuery 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); + $this->addUsingAlias(CurrencyTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CurrencyPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CurrencyTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -555,30 +537,29 @@ abstract class BaseCurrencyQuery extends ModelCriteria } } - return $this->addUsingAlias(CurrencyPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CurrencyTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Order object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Order|ObjectCollection $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. + * @return ChildCurrencyQuery The current query, for fluid interface */ public function filterByOrder($order, $comparison = null) { - if ($order instanceof Order) { + if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(CurrencyPeer::ID, $order->getCurrencyId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { + ->addUsingAlias(CurrencyTableMap::ID, $order->getCurrencyId(), $comparison); + } elseif ($order instanceof ObjectCollection) { return $this ->useOrderQuery() ->filterByPrimaryKeys($order->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); + throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); } } @@ -588,7 +569,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria * @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 + * @return ChildCurrencyQuery The current query, for fluid interface */ public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -617,7 +598,7 @@ abstract class BaseCurrencyQuery extends ModelCriteria /** * Use the Order relation Order object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -635,19 +616,94 @@ abstract class BaseCurrencyQuery extends ModelCriteria /** * Exclude object from result * - * @param Currency $currency Object to remove from the list of results + * @param ChildCurrency $currency Object to remove from the list of results * - * @return CurrencyQuery The current query, for fluid interface + * @return ChildCurrencyQuery The current query, for fluid interface */ public function prune($currency = null) { if ($currency) { - $this->addUsingAlias(CurrencyPeer::ID, $currency->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(CurrencyTableMap::ID, $currency->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the currency table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CurrencyTableMap::clearInstancePool(); + CurrencyTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCurrency or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCurrency object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CurrencyTableMap::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(); + + + CurrencyTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CurrencyTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -655,31 +711,11 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return CurrencyQuery The current query, for fluid interface + * @return ChildCurrencyQuery 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); + return $this->addUsingAlias(CurrencyTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -687,30 +723,51 @@ abstract class BaseCurrencyQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return CurrencyQuery The current query, for fluid interface + * @return ChildCurrencyQuery 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); + return $this->addUsingAlias(CurrencyTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCurrencyQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CurrencyTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCurrencyQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CurrencyTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return CurrencyQuery The current query, for fluid interface + * @return ChildCurrencyQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(CurrencyPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(CurrencyTableMap::CREATED_AT); } /** * Order by create date asc * - * @return CurrencyQuery The current query, for fluid interface + * @return ChildCurrencyQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(CurrencyPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(CurrencyTableMap::CREATED_AT); } -} + +} // CurrencyQuery diff --git a/core/lib/Thelia/Model/om/BaseCustomer.php b/core/lib/Thelia/Model/Base/Customer.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseCustomer.php rename to core/lib/Thelia/Model/Base/Customer.php index 6935ed1ea..6941594a0 --- a/core/lib/Thelia/Model/om/BaseCustomer.php +++ b/core/lib/Thelia/Model/Base/Customer.php @@ -1,57 +1,65 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Customer instance. If + * obj is an instance of Customer, delegates to + * equals(Customer). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Customer The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Customer The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [ref] column value. * - * @return string + * @return string */ public function getRef() { + return $this->ref; } /** * Get the [customer_title_id] column value. * - * @return int + * @return int */ public function getCustomerTitleId() { + return $this->customer_title_id; } /** * Get the [company] column value. * - * @return string + * @return string */ public function getCompany() { + return $this->company; } /** * Get the [firstname] column value. * - * @return string + * @return string */ public function getFirstname() { + return $this->firstname; } /** * Get the [lastname] column value. * - * @return string + * @return string */ public function getLastname() { + return $this->lastname; } /** * Get the [address1] column value. * - * @return string + * @return string */ public function getAddress1() { + return $this->address1; } /** * Get the [address2] column value. * - * @return string + * @return string */ public function getAddress2() { + return $this->address2; } /** * Get the [address3] column value. * - * @return string + * @return string */ public function getAddress3() { + return $this->address3; } /** * Get the [zipcode] column value. * - * @return string + * @return string */ public function getZipcode() { + return $this->zipcode; } /** * Get the [city] column value. * - * @return string + * @return string */ public function getCity() { + return $this->city; } /** * Get the [country_id] column value. * - * @return int + * @return int */ public function getCountryId() { + return $this->country_id; } /** * Get the [phone] column value. * - * @return string + * @return string */ public function getPhone() { + return $this->phone; } /** * Get the [cellphone] column value. * - * @return string + * @return string */ public function getCellphone() { + return $this->cellphone; } /** * Get the [email] column value. * - * @return string + * @return string */ public function getEmail() { + return $this->email; } /** * Get the [password] column value. * - * @return string + * @return string */ public function getPassword() { + return $this->password; } /** * Get the [algo] column value. * - * @return string + * @return string */ public function getAlgo() { + return $this->algo; } /** * Get the [salt] column value. * - * @return string + * @return string */ public function getSalt() { + return $this->salt; } /** * Get the [reseller] column value. * - * @return int + * @return int */ public function getReseller() { + return $this->reseller; } /** * Get the [lang] column value. * - * @return string + * @return string */ public function getLang() { + return $this->lang; } /** * Get the [sponsor] column value. * - * @return string + * @return string */ public function getSponsor() { + return $this->sponsor; } /** * Get the [discount] column value. * - * @return double + * @return double */ public function getDiscount() { + return $this->discount; } @@ -470,97 +742,57 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = CustomerPeer::ID; + $this->modifiedColumns[] = CustomerTableMap::ID; } @@ -570,18 +802,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [ref] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setRef($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->ref !== $v) { $this->ref = $v; - $this->modifiedColumns[] = CustomerPeer::REF; + $this->modifiedColumns[] = CustomerTableMap::REF; } @@ -591,18 +823,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [customer_title_id] column. * - * @param int $v new value - * @return Customer The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setCustomerTitleId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->customer_title_id !== $v) { $this->customer_title_id = $v; - $this->modifiedColumns[] = CustomerPeer::CUSTOMER_TITLE_ID; + $this->modifiedColumns[] = CustomerTableMap::CUSTOMER_TITLE_ID; } if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) { @@ -616,18 +848,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [company] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setCompany($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->company !== $v) { $this->company = $v; - $this->modifiedColumns[] = CustomerPeer::COMPANY; + $this->modifiedColumns[] = CustomerTableMap::COMPANY; } @@ -637,18 +869,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [firstname] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setFirstname($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->firstname !== $v) { $this->firstname = $v; - $this->modifiedColumns[] = CustomerPeer::FIRSTNAME; + $this->modifiedColumns[] = CustomerTableMap::FIRSTNAME; } @@ -658,18 +890,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [lastname] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setLastname($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->lastname !== $v) { $this->lastname = $v; - $this->modifiedColumns[] = CustomerPeer::LASTNAME; + $this->modifiedColumns[] = CustomerTableMap::LASTNAME; } @@ -679,18 +911,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [address1] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setAddress1($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->address1 !== $v) { $this->address1 = $v; - $this->modifiedColumns[] = CustomerPeer::ADDRESS1; + $this->modifiedColumns[] = CustomerTableMap::ADDRESS1; } @@ -700,18 +932,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [address2] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setAddress2($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->address2 !== $v) { $this->address2 = $v; - $this->modifiedColumns[] = CustomerPeer::ADDRESS2; + $this->modifiedColumns[] = CustomerTableMap::ADDRESS2; } @@ -721,18 +953,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [address3] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setAddress3($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->address3 !== $v) { $this->address3 = $v; - $this->modifiedColumns[] = CustomerPeer::ADDRESS3; + $this->modifiedColumns[] = CustomerTableMap::ADDRESS3; } @@ -742,18 +974,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [zipcode] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setZipcode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->zipcode !== $v) { $this->zipcode = $v; - $this->modifiedColumns[] = CustomerPeer::ZIPCODE; + $this->modifiedColumns[] = CustomerTableMap::ZIPCODE; } @@ -763,18 +995,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [city] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setCity($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->city !== $v) { $this->city = $v; - $this->modifiedColumns[] = CustomerPeer::CITY; + $this->modifiedColumns[] = CustomerTableMap::CITY; } @@ -784,18 +1016,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [country_id] column. * - * @param int $v new value - * @return Customer The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setCountryId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->country_id !== $v) { $this->country_id = $v; - $this->modifiedColumns[] = CustomerPeer::COUNTRY_ID; + $this->modifiedColumns[] = CustomerTableMap::COUNTRY_ID; } @@ -805,18 +1037,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [phone] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setPhone($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->phone !== $v) { $this->phone = $v; - $this->modifiedColumns[] = CustomerPeer::PHONE; + $this->modifiedColumns[] = CustomerTableMap::PHONE; } @@ -826,18 +1058,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [cellphone] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setCellphone($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->cellphone !== $v) { $this->cellphone = $v; - $this->modifiedColumns[] = CustomerPeer::CELLPHONE; + $this->modifiedColumns[] = CustomerTableMap::CELLPHONE; } @@ -847,18 +1079,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [email] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setEmail($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->email !== $v) { $this->email = $v; - $this->modifiedColumns[] = CustomerPeer::EMAIL; + $this->modifiedColumns[] = CustomerTableMap::EMAIL; } @@ -868,18 +1100,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [password] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setPassword($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->password !== $v) { $this->password = $v; - $this->modifiedColumns[] = CustomerPeer::PASSWORD; + $this->modifiedColumns[] = CustomerTableMap::PASSWORD; } @@ -889,18 +1121,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [algo] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setAlgo($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->algo !== $v) { $this->algo = $v; - $this->modifiedColumns[] = CustomerPeer::ALGO; + $this->modifiedColumns[] = CustomerTableMap::ALGO; } @@ -910,18 +1142,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [salt] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setSalt($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->salt !== $v) { $this->salt = $v; - $this->modifiedColumns[] = CustomerPeer::SALT; + $this->modifiedColumns[] = CustomerTableMap::SALT; } @@ -931,18 +1163,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [reseller] column. * - * @param int $v new value - * @return Customer The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setReseller($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->reseller !== $v) { $this->reseller = $v; - $this->modifiedColumns[] = CustomerPeer::RESELLER; + $this->modifiedColumns[] = CustomerTableMap::RESELLER; } @@ -952,18 +1184,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [lang] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setLang($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->lang !== $v) { $this->lang = $v; - $this->modifiedColumns[] = CustomerPeer::LANG; + $this->modifiedColumns[] = CustomerTableMap::LANG; } @@ -973,18 +1205,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [sponsor] column. * - * @param string $v new value - * @return Customer The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setSponsor($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->sponsor !== $v) { $this->sponsor = $v; - $this->modifiedColumns[] = CustomerPeer::SPONSOR; + $this->modifiedColumns[] = CustomerTableMap::SPONSOR; } @@ -994,18 +1226,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Set the value of [discount] column. * - * @param double $v new value - * @return Customer The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setDiscount($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->discount !== $v) { $this->discount = $v; - $this->modifiedColumns[] = CustomerPeer::DISCOUNT; + $this->modifiedColumns[] = CustomerTableMap::DISCOUNT; } @@ -1015,19 +1247,17 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CustomerTableMap::CREATED_AT; } } // if either are not null @@ -1038,19 +1268,17 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Customer The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CustomerTableMap::UPDATED_AT; } } // if either are not null @@ -1068,7 +1296,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -1080,40 +1308,98 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->customer_title_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)]; + $this->company = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->firstname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : CustomerTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lastname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : CustomerTableMap::translateFieldName('Address1', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address1 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : CustomerTableMap::translateFieldName('Address2', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address2 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CustomerTableMap::translateFieldName('Address3', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address3 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CustomerTableMap::translateFieldName('Zipcode', TableMap::TYPE_PHPNAME, $indexType)]; + $this->zipcode = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CustomerTableMap::translateFieldName('City', TableMap::TYPE_PHPNAME, $indexType)]; + $this->city = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CustomerTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->country_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : CustomerTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)]; + $this->phone = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : CustomerTableMap::translateFieldName('Cellphone', TableMap::TYPE_PHPNAME, $indexType)]; + $this->cellphone = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : CustomerTableMap::translateFieldName('Email', TableMap::TYPE_PHPNAME, $indexType)]; + $this->email = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : CustomerTableMap::translateFieldName('Password', TableMap::TYPE_PHPNAME, $indexType)]; + $this->password = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : CustomerTableMap::translateFieldName('Algo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->algo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : CustomerTableMap::translateFieldName('Salt', TableMap::TYPE_PHPNAME, $indexType)]; + $this->salt = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 18 + $startcol : CustomerTableMap::translateFieldName('Reseller', TableMap::TYPE_PHPNAME, $indexType)]; + $this->reseller = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 19 + $startcol : CustomerTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lang = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 20 + $startcol : CustomerTableMap::translateFieldName('Sponsor', TableMap::TYPE_PHPNAME, $indexType)]; + $this->sponsor = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 21 + $startcol : CustomerTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->discount = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 22 + $startcol : CustomerTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 23 + $startcol : CustomerTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -1121,11 +1407,11 @@ abstract class BaseCustomer extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 24; // 24 = CustomerPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 24; // 24 = CustomerTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Customer object", $e); + throw new PropelException("Error populating \Thelia\Model\Customer object", 0, $e); } } @@ -1144,7 +1430,6 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) { $this->aCustomerTitle = null; } @@ -1155,12 +1440,12 @@ abstract class BaseCustomer extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -1171,24 +1456,24 @@ abstract class BaseCustomer extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CustomerTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildCustomerQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? $this->aCustomerTitle = null; - $this->collAddresss = null; + $this->collAddresses = null; $this->collOrders = null; @@ -1198,26 +1483,25 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Customer::setDeleted() + * @see Customer::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = CustomerQuery::create() + $deleteQuery = ChildCustomerQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -1242,20 +1526,19 @@ abstract class BaseCustomer extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -1265,16 +1548,16 @@ abstract class BaseCustomer extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(CustomerPeer::CREATED_AT)) { + if (!$this->isColumnModified(CustomerTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(CustomerPeer::UPDATED_AT)) { + if (!$this->isColumnModified(CustomerTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CustomerPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(CustomerTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -1286,7 +1569,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - CustomerPeer::addInstanceToPool($this); + CustomerTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1305,19 +1588,19 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -1339,17 +1622,17 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->resetModified(); } - if ($this->addresssScheduledForDeletion !== null) { - if (!$this->addresssScheduledForDeletion->isEmpty()) { - AddressQuery::create() - ->filterByPrimaryKeys($this->addresssScheduledForDeletion->getPrimaryKeys(false)) + if ($this->addressesScheduledForDeletion !== null) { + if (!$this->addressesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AddressQuery::create() + ->filterByPrimaryKeys($this->addressesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->addresssScheduledForDeletion = null; + $this->addressesScheduledForDeletion = null; } } - if ($this->collAddresss !== null) { - foreach ($this->collAddresss as $referrerFK) { + if ($this->collAddresses !== null) { + foreach ($this->collAddresses as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1358,15 +1641,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent if ($this->ordersScheduledForDeletion !== null) { if (!$this->ordersScheduledForDeletion->isEmpty()) { - OrderQuery::create() + \Thelia\Model\OrderQuery::create() ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->ordersScheduledForDeletion = null; } } - if ($this->collOrders !== null) { - foreach ($this->collOrders as $referrerFK) { + if ($this->collOrders !== null) { + foreach ($this->collOrders as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1383,97 +1666,97 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = CustomerPeer::ID; + $this->modifiedColumns[] = CustomerTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CustomerPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(CustomerTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(CustomerPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; + if ($this->isColumnModified(CustomerTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; } - if ($this->isColumnModified(CustomerPeer::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_title_id`'; + if ($this->isColumnModified(CustomerTableMap::CUSTOMER_TITLE_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID'; } - if ($this->isColumnModified(CustomerPeer::COMPANY)) { - $modifiedColumns[':p' . $index++] = '`company`'; + if ($this->isColumnModified(CustomerTableMap::COMPANY)) { + $modifiedColumns[':p' . $index++] = 'COMPANY'; } - if ($this->isColumnModified(CustomerPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`firstname`'; + if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) { + $modifiedColumns[':p' . $index++] = 'FIRSTNAME'; } - if ($this->isColumnModified(CustomerPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`lastname`'; + if ($this->isColumnModified(CustomerTableMap::LASTNAME)) { + $modifiedColumns[':p' . $index++] = 'LASTNAME'; } - if ($this->isColumnModified(CustomerPeer::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = '`address1`'; + if ($this->isColumnModified(CustomerTableMap::ADDRESS1)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS1'; } - if ($this->isColumnModified(CustomerPeer::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = '`address2`'; + if ($this->isColumnModified(CustomerTableMap::ADDRESS2)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS2'; } - if ($this->isColumnModified(CustomerPeer::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = '`address3`'; + if ($this->isColumnModified(CustomerTableMap::ADDRESS3)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS3'; } - if ($this->isColumnModified(CustomerPeer::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = '`zipcode`'; + if ($this->isColumnModified(CustomerTableMap::ZIPCODE)) { + $modifiedColumns[':p' . $index++] = 'ZIPCODE'; } - if ($this->isColumnModified(CustomerPeer::CITY)) { - $modifiedColumns[':p' . $index++] = '`city`'; + if ($this->isColumnModified(CustomerTableMap::CITY)) { + $modifiedColumns[':p' . $index++] = 'CITY'; } - if ($this->isColumnModified(CustomerPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`country_id`'; + if ($this->isColumnModified(CustomerTableMap::COUNTRY_ID)) { + $modifiedColumns[':p' . $index++] = 'COUNTRY_ID'; } - if ($this->isColumnModified(CustomerPeer::PHONE)) { - $modifiedColumns[':p' . $index++] = '`phone`'; + if ($this->isColumnModified(CustomerTableMap::PHONE)) { + $modifiedColumns[':p' . $index++] = 'PHONE'; } - if ($this->isColumnModified(CustomerPeer::CELLPHONE)) { - $modifiedColumns[':p' . $index++] = '`cellphone`'; + if ($this->isColumnModified(CustomerTableMap::CELLPHONE)) { + $modifiedColumns[':p' . $index++] = 'CELLPHONE'; } - if ($this->isColumnModified(CustomerPeer::EMAIL)) { - $modifiedColumns[':p' . $index++] = '`email`'; + if ($this->isColumnModified(CustomerTableMap::EMAIL)) { + $modifiedColumns[':p' . $index++] = 'EMAIL'; } - if ($this->isColumnModified(CustomerPeer::PASSWORD)) { - $modifiedColumns[':p' . $index++] = '`password`'; + if ($this->isColumnModified(CustomerTableMap::PASSWORD)) { + $modifiedColumns[':p' . $index++] = 'PASSWORD'; } - if ($this->isColumnModified(CustomerPeer::ALGO)) { - $modifiedColumns[':p' . $index++] = '`algo`'; + if ($this->isColumnModified(CustomerTableMap::ALGO)) { + $modifiedColumns[':p' . $index++] = 'ALGO'; } - if ($this->isColumnModified(CustomerPeer::SALT)) { - $modifiedColumns[':p' . $index++] = '`salt`'; + if ($this->isColumnModified(CustomerTableMap::SALT)) { + $modifiedColumns[':p' . $index++] = 'SALT'; } - if ($this->isColumnModified(CustomerPeer::RESELLER)) { - $modifiedColumns[':p' . $index++] = '`reseller`'; + if ($this->isColumnModified(CustomerTableMap::RESELLER)) { + $modifiedColumns[':p' . $index++] = 'RESELLER'; } - if ($this->isColumnModified(CustomerPeer::LANG)) { - $modifiedColumns[':p' . $index++] = '`lang`'; + if ($this->isColumnModified(CustomerTableMap::LANG)) { + $modifiedColumns[':p' . $index++] = 'LANG'; } - if ($this->isColumnModified(CustomerPeer::SPONSOR)) { - $modifiedColumns[':p' . $index++] = '`sponsor`'; + if ($this->isColumnModified(CustomerTableMap::SPONSOR)) { + $modifiedColumns[':p' . $index++] = 'SPONSOR'; } - if ($this->isColumnModified(CustomerPeer::DISCOUNT)) { - $modifiedColumns[':p' . $index++] = '`discount`'; + if ($this->isColumnModified(CustomerTableMap::DISCOUNT)) { + $modifiedColumns[':p' . $index++] = 'DISCOUNT'; } - if ($this->isColumnModified(CustomerPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(CustomerTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(CustomerPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(CustomerTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `customer` (%s) VALUES (%s)', + 'INSERT INTO customer (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1482,90 +1765,90 @@ abstract class BaseCustomer extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`ref`': + case 'REF': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`customer_title_id`': + case 'CUSTOMER_TITLE_ID': $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); break; - case '`company`': + case 'COMPANY': $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); break; - case '`firstname`': + case 'FIRSTNAME': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; - case '`lastname`': + case 'LASTNAME': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; - case '`address1`': + case 'ADDRESS1': $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); break; - case '`address2`': + case 'ADDRESS2': $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); break; - case '`address3`': + case 'ADDRESS3': $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); break; - case '`zipcode`': + case 'ZIPCODE': $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); break; - case '`city`': + case 'CITY': $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); break; - case '`country_id`': + case 'COUNTRY_ID': $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); break; - case '`phone`': + case 'PHONE': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; - case '`cellphone`': + case 'CELLPHONE': $stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR); break; - case '`email`': + case 'EMAIL': $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); break; - case '`password`': + case 'PASSWORD': $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); break; - case '`algo`': + case 'ALGO': $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR); break; - case '`salt`': + case 'SALT': $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); break; - case '`reseller`': + case 'RESELLER': $stmt->bindValue($identifier, $this->reseller, PDO::PARAM_INT); break; - case '`lang`': + case 'LANG': $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR); break; - case '`sponsor`': + case 'SPONSOR': $stmt->bindValue($identifier, $this->sponsor, PDO::PARAM_STR); break; - case '`discount`': + case 'DISCOUNT': $stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -1575,132 +1858,32 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = CustomerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CustomerTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1710,7 +1893,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1800,22 +1983,22 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = CustomerTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getRef(), @@ -1842,12 +2025,18 @@ abstract class BaseCustomer extends BaseObject implements Persistent $keys[22] => $this->getCreatedAt(), $keys[23] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + 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->collAddresses) { + $result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collOrders) { $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1860,27 +2049,27 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = CustomerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CustomerTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1970,17 +2159,17 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = CustomerPeer::getFieldNames($keyType); + $keys = CustomerTableMap::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]]); @@ -2015,32 +2204,32 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(CustomerPeer::DATABASE_NAME); + $criteria = new Criteria(CustomerTableMap::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); + if ($this->isColumnModified(CustomerTableMap::ID)) $criteria->add(CustomerTableMap::ID, $this->id); + if ($this->isColumnModified(CustomerTableMap::REF)) $criteria->add(CustomerTableMap::REF, $this->ref); + if ($this->isColumnModified(CustomerTableMap::CUSTOMER_TITLE_ID)) $criteria->add(CustomerTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id); + if ($this->isColumnModified(CustomerTableMap::COMPANY)) $criteria->add(CustomerTableMap::COMPANY, $this->company); + if ($this->isColumnModified(CustomerTableMap::FIRSTNAME)) $criteria->add(CustomerTableMap::FIRSTNAME, $this->firstname); + if ($this->isColumnModified(CustomerTableMap::LASTNAME)) $criteria->add(CustomerTableMap::LASTNAME, $this->lastname); + if ($this->isColumnModified(CustomerTableMap::ADDRESS1)) $criteria->add(CustomerTableMap::ADDRESS1, $this->address1); + if ($this->isColumnModified(CustomerTableMap::ADDRESS2)) $criteria->add(CustomerTableMap::ADDRESS2, $this->address2); + if ($this->isColumnModified(CustomerTableMap::ADDRESS3)) $criteria->add(CustomerTableMap::ADDRESS3, $this->address3); + if ($this->isColumnModified(CustomerTableMap::ZIPCODE)) $criteria->add(CustomerTableMap::ZIPCODE, $this->zipcode); + if ($this->isColumnModified(CustomerTableMap::CITY)) $criteria->add(CustomerTableMap::CITY, $this->city); + if ($this->isColumnModified(CustomerTableMap::COUNTRY_ID)) $criteria->add(CustomerTableMap::COUNTRY_ID, $this->country_id); + if ($this->isColumnModified(CustomerTableMap::PHONE)) $criteria->add(CustomerTableMap::PHONE, $this->phone); + if ($this->isColumnModified(CustomerTableMap::CELLPHONE)) $criteria->add(CustomerTableMap::CELLPHONE, $this->cellphone); + if ($this->isColumnModified(CustomerTableMap::EMAIL)) $criteria->add(CustomerTableMap::EMAIL, $this->email); + if ($this->isColumnModified(CustomerTableMap::PASSWORD)) $criteria->add(CustomerTableMap::PASSWORD, $this->password); + if ($this->isColumnModified(CustomerTableMap::ALGO)) $criteria->add(CustomerTableMap::ALGO, $this->algo); + if ($this->isColumnModified(CustomerTableMap::SALT)) $criteria->add(CustomerTableMap::SALT, $this->salt); + if ($this->isColumnModified(CustomerTableMap::RESELLER)) $criteria->add(CustomerTableMap::RESELLER, $this->reseller); + if ($this->isColumnModified(CustomerTableMap::LANG)) $criteria->add(CustomerTableMap::LANG, $this->lang); + if ($this->isColumnModified(CustomerTableMap::SPONSOR)) $criteria->add(CustomerTableMap::SPONSOR, $this->sponsor); + if ($this->isColumnModified(CustomerTableMap::DISCOUNT)) $criteria->add(CustomerTableMap::DISCOUNT, $this->discount); + if ($this->isColumnModified(CustomerTableMap::CREATED_AT)) $criteria->add(CustomerTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CustomerTableMap::UPDATED_AT)) $criteria->add(CustomerTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -2055,15 +2244,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(CustomerPeer::DATABASE_NAME); - $criteria->add(CustomerPeer::ID, $this->id); + $criteria = new Criteria(CustomerTableMap::DATABASE_NAME); + $criteria->add(CustomerTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -2073,7 +2262,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -2097,9 +2286,9 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -2128,14 +2317,12 @@ abstract class BaseCustomer extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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) { + foreach ($this->getAddresses() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addAddress($relObj->copy($deepCopy)); } @@ -2147,8 +2334,6 @@ abstract class BaseCustomer extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -2165,8 +2350,8 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Customer Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -2180,31 +2365,13 @@ abstract class BaseCustomer extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildCustomerTitle object. * - * 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) + * @param ChildCustomerTitle $v + * @return \Thelia\Model\Customer The current object (for fluent API support) * @throws PropelException */ - public function setCustomerTitle(CustomerTitle $v = null) + public function setCustomerTitle(ChildCustomerTitle $v = null) { if ($v === null) { $this->setCustomerTitleId(NULL); @@ -2215,7 +2382,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent $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 this object has already been added to the ChildCustomerTitle object, it will not be re-added. if ($v !== null) { $v->addCustomer($this); } @@ -2226,17 +2393,16 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** - * Get the associated CustomerTitle object + * Get the associated ChildCustomerTitle object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return CustomerTitle The associated CustomerTitle object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCustomerTitle The associated ChildCustomerTitle object. * @throws PropelException */ - public function getCustomerTitle(PropelPDO $con = null, $doQuery = true) + public function getCustomerTitle(ConnectionInterface $con = null) { - if ($this->aCustomerTitle === null && ($this->customer_title_id !== null) && $doQuery) { - $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_id, $con); + if ($this->aCustomerTitle === null && ($this->customer_title_id !== null)) { + $this->aCustomerTitle = ChildCustomerTitleQuery::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 @@ -2255,123 +2421,120 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('Address' == $relationName) { - $this->initAddresss(); + return $this->initAddresses(); } if ('Order' == $relationName) { - $this->initOrders(); + return $this->initOrders(); } } /** - * Clears out the collAddresss collection + * Clears out the collAddresses collection * * This 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 + * @see addAddresses() */ - public function resetPartialAddresss($v = true) + public function clearAddresses() { - $this->collAddresssPartial = $v; + $this->collAddresses = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collAddresss collection. + * Reset is the collAddresses collection loaded partially. + */ + public function resetPartialAddresses($v = true) + { + $this->collAddressesPartial = $v; + } + + /** + * Initializes the collAddresses collection. * - * By default this just sets the collAddresss collection to an empty array (like clearcollAddresss()); + * By default this just sets the collAddresses collection to an empty array (like clearcollAddresses()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initAddresses($overrideExisting = true) { - if (null !== $this->collAddresss && !$overrideExisting) { + if (null !== $this->collAddresses && !$overrideExisting) { return; } - $this->collAddresss = new PropelObjectCollection(); - $this->collAddresss->setModel('Address'); + $this->collAddresses = new ObjectCollection(); + $this->collAddresses->setModel('\Thelia\Model\Address'); } /** - * Gets an array of Address objects which contain a foreign key that references this object. + * Gets an array of ChildAddress objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCustomer is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAddress[] List of ChildAddress objects * @throws PropelException */ - public function getAddresss($criteria = null, PropelPDO $con = null) + public function getAddresses($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collAddresssPartial && !$this->isNew(); - if (null === $this->collAddresss || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAddresss) { + $partial = $this->collAddressesPartial && !$this->isNew(); + if (null === $this->collAddresses || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAddresses) { // return empty collection - $this->initAddresss(); + $this->initAddresses(); } else { - $collAddresss = AddressQuery::create(null, $criteria) + $collAddresses = ChildAddressQuery::create(null, $criteria) ->filterByCustomer($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collAddresssPartial && count($collAddresss)) { - $this->initAddresss(false); + if (false !== $this->collAddressesPartial && count($collAddresses)) { + $this->initAddresses(false); - foreach($collAddresss as $obj) { - if (false == $this->collAddresss->contains($obj)) { - $this->collAddresss->append($obj); + foreach ($collAddresses as $obj) { + if (false == $this->collAddresses->contains($obj)) { + $this->collAddresses->append($obj); + } } - } - $this->collAddresssPartial = true; + $this->collAddressesPartial = true; } - $collAddresss->getInternalIterator()->rewind(); - return $collAddresss; + $collAddresses->getInternalIterator()->rewind(); + + return $collAddresses; } - if($partial && $this->collAddresss) { - foreach($this->collAddresss as $obj) { - if($obj->isNew()) { - $collAddresss[] = $obj; + if ($partial && $this->collAddresses) { + foreach ($this->collAddresses as $obj) { + if ($obj->isNew()) { + $collAddresses[] = $obj; } } } - $this->collAddresss = $collAddresss; - $this->collAddresssPartial = false; + $this->collAddresses = $collAddresses; + $this->collAddressesPartial = false; } } - return $this->collAddresss; + return $this->collAddresses; } /** @@ -2380,27 +2543,28 @@ abstract class BaseCustomer extends BaseObject implements Persistent * It will 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) + * @param Collection $addresses A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCustomer The current object (for fluent API support) */ - public function setAddresss(PropelCollection $addresss, PropelPDO $con = null) + public function setAddresses(Collection $addresses, ConnectionInterface $con = null) { - $addresssToDelete = $this->getAddresss(new Criteria(), $con)->diff($addresss); + $addressesToDelete = $this->getAddresses(new Criteria(), $con)->diff($addresses); - $this->addresssScheduledForDeletion = unserialize(serialize($addresssToDelete)); - foreach ($addresssToDelete as $addressRemoved) { + $this->addressesScheduledForDeletion = $addressesToDelete; + + foreach ($addressesToDelete as $addressRemoved) { $addressRemoved->setCustomer(null); } - $this->collAddresss = null; - foreach ($addresss as $address) { + $this->collAddresses = null; + foreach ($addresses as $address) { $this->addAddress($address); } - $this->collAddresss = $addresss; - $this->collAddresssPartial = false; + $this->collAddresses = $addresses; + $this->collAddressesPartial = false; return $this; } @@ -2408,24 +2572,25 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Returns the number of related Address objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Address objects. * @throws PropelException */ - public function countAddresss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAddresses(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collAddresssPartial && !$this->isNew(); - if (null === $this->collAddresss || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAddresss) { + $partial = $this->collAddressesPartial && !$this->isNew(); + if (null === $this->collAddresses || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAddresses) { return 0; } - if($partial && !$criteria) { - return count($this->getAddresss()); + if ($partial && !$criteria) { + return count($this->getAddresses()); } - $query = AddressQuery::create(null, $criteria); + + $query = ChildAddressQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2435,23 +2600,24 @@ abstract class BaseCustomer extends BaseObject implements Persistent ->count($con); } - return count($this->collAddresss); + return count($this->collAddresses); } /** - * Method called to associate a Address object to this object - * through the Address foreign key attribute. + * Method called to associate a ChildAddress object to this object + * through the ChildAddress foreign key attribute. * - * @param Address $l Address - * @return Customer The current object (for fluent API support) + * @param ChildAddress $l ChildAddress + * @return \Thelia\Model\Customer The current object (for fluent API support) */ - public function addAddress(Address $l) + public function addAddress(ChildAddress $l) { - if ($this->collAddresss === null) { - $this->initAddresss(); - $this->collAddresssPartial = true; + if ($this->collAddresses === null) { + $this->initAddresses(); + $this->collAddressesPartial = true; } - if (!in_array($l, $this->collAddresss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collAddresses->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAddress($l); } @@ -2459,27 +2625,27 @@ abstract class BaseCustomer extends BaseObject implements Persistent } /** - * @param Address $address The address object to add. + * @param Address $address The address object to add. */ protected function doAddAddress($address) { - $this->collAddresss[]= $address; + $this->collAddresses[]= $address; $address->setCustomer($this); } /** - * @param Address $address The address object to remove. - * @return Customer The current object (for fluent API support) + * @param Address $address The address object to remove. + * @return ChildCustomer 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(); + if ($this->getAddresses()->contains($address)) { + $this->collAddresses->remove($this->collAddresses->search($address)); + if (null === $this->addressesScheduledForDeletion) { + $this->addressesScheduledForDeletion = clone $this->collAddresses; + $this->addressesScheduledForDeletion->clear(); } - $this->addresssScheduledForDeletion[]= clone $address; + $this->addressesScheduledForDeletion[]= clone $address; $address->setCustomer(null); } @@ -2492,23 +2658,23 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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. + * been saved, it will retrieve related Addresses from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAddress[] List of ChildAddress objects */ - public function getAddresssJoinCustomerTitle($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAddressesJoinCustomerTitle($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AddressQuery::create(null, $criteria); - $query->joinWith('CustomerTitle', $join_behavior); + $query = ChildAddressQuery::create(null, $criteria); + $query->joinWith('CustomerTitle', $joinBehavior); - return $this->getAddresss($query, $con); + return $this->getAddresses($query, $con); } /** @@ -2517,21 +2683,16 @@ abstract class BaseCustomer extends BaseObject implements Persistent * This 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) + * @return void * @see addOrders() */ public function clearOrders() { - $this->collOrders = null; // important to set this to null since that means it is uninitialized - $this->collOrdersPartial = null; - - return $this; + $this->collOrders = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collOrders collection loaded partially - * - * @return void + * Reset is the collOrders collection loaded partially. */ public function resetPartialOrders($v = true) { @@ -2545,7 +2706,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2555,25 +2716,25 @@ abstract class BaseCustomer extends BaseObject implements Persistent if (null !== $this->collOrders && !$overrideExisting) { return; } - $this->collOrders = new PropelObjectCollection(); - $this->collOrders->setModel('Order'); + $this->collOrders = new ObjectCollection(); + $this->collOrders->setModel('\Thelia\Model\Order'); } /** - * Gets an array of Order objects which contain a foreign key that references this object. + * Gets an array of ChildOrder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCustomer is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects * @throws PropelException */ - public function getOrders($criteria = null, PropelPDO $con = null) + public function getOrders($criteria = null, ConnectionInterface $con = null) { $partial = $this->collOrdersPartial && !$this->isNew(); if (null === $this->collOrders || null !== $criteria || $partial) { @@ -2581,29 +2742,31 @@ abstract class BaseCustomer extends BaseObject implements Persistent // return empty collection $this->initOrders(); } else { - $collOrders = OrderQuery::create(null, $criteria) + $collOrders = ChildOrderQuery::create(null, $criteria) ->filterByCustomer($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collOrdersPartial && count($collOrders)) { - $this->initOrders(false); + $this->initOrders(false); - foreach($collOrders as $obj) { - if (false == $this->collOrders->contains($obj)) { - $this->collOrders->append($obj); + foreach ($collOrders as $obj) { + if (false == $this->collOrders->contains($obj)) { + $this->collOrders->append($obj); + } } - } - $this->collOrdersPartial = true; + $this->collOrdersPartial = true; } $collOrders->getInternalIterator()->rewind(); + return $collOrders; } - if($partial && $this->collOrders) { - foreach($this->collOrders as $obj) { - if($obj->isNew()) { + if ($partial && $this->collOrders) { + foreach ($this->collOrders as $obj) { + if ($obj->isNew()) { $collOrders[] = $obj; } } @@ -2623,15 +2786,16 @@ abstract class BaseCustomer extends BaseObject implements Persistent * It will 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) + * @param Collection $orders A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCustomer The current object (for fluent API support) */ - public function setOrders(PropelCollection $orders, PropelPDO $con = null) + public function setOrders(Collection $orders, ConnectionInterface $con = null) { $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); - $this->ordersScheduledForDeletion = unserialize(serialize($ordersToDelete)); + + $this->ordersScheduledForDeletion = $ordersToDelete; foreach ($ordersToDelete as $orderRemoved) { $orderRemoved->setCustomer(null); @@ -2651,13 +2815,13 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * Returns the number of related Order objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Order objects. * @throws PropelException */ - public function countOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collOrdersPartial && !$this->isNew(); if (null === $this->collOrders || null !== $criteria || $partial) { @@ -2665,10 +2829,11 @@ abstract class BaseCustomer extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getOrders()); } - $query = OrderQuery::create(null, $criteria); + + $query = ChildOrderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2682,18 +2847,19 @@ abstract class BaseCustomer extends BaseObject implements Persistent } /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. * - * @param Order $l Order - * @return Customer The current object (for fluent API support) + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\Customer The current object (for fluent API support) */ - public function addOrder(Order $l) + public function addOrder(ChildOrder $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); } @@ -2702,7 +2868,7 @@ abstract class BaseCustomer extends BaseObject implements Persistent } /** - * @param Order $order The order object to add. + * @param Order $order The order object to add. */ protected function doAddOrder($order) { @@ -2711,8 +2877,8 @@ abstract class BaseCustomer extends BaseObject implements Persistent } /** - * @param Order $order The order object to remove. - * @return Customer The current object (for fluent API support) + * @param Order $order The order object to remove. + * @return ChildCustomer The current object (for fluent API support) */ public function removeOrder($order) { @@ -2741,15 +2907,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Currency', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); return $this->getOrders($query, $con); } @@ -2766,15 +2932,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior); return $this->getOrders($query, $con); } @@ -2791,15 +2957,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior); return $this->getOrders($query, $con); } @@ -2816,15 +2982,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderStatus', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); return $this->getOrders($query, $con); } @@ -2859,8 +3025,6 @@ abstract class BaseCustomer extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2872,16 +3036,15 @@ abstract class BaseCustomer extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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) { + if ($deep) { + if ($this->collAddresses) { + foreach ($this->collAddresses as $o) { $o->clearAllReferences($deep); } } @@ -2890,18 +3053,13 @@ abstract class BaseCustomer extends BaseObject implements Persistent $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(); + if ($this->collAddresses instanceof Collection) { + $this->collAddresses->clearIterator(); } - $this->collAddresss = null; - if ($this->collOrders instanceof PropelCollection) { + $this->collAddresses = null; + if ($this->collOrders instanceof Collection) { $this->collOrders->clearIterator(); } $this->collOrders = null; @@ -2909,23 +3067,13 @@ abstract class BaseCustomer extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(CustomerTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2933,13 +3081,131 @@ abstract class BaseCustomer extends BaseObject implements Persistent /** * 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) + * @return ChildCustomer The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = CustomerPeer::UPDATED_AT; + $this->modifiedColumns[] = CustomerTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseCustomerQuery.php b/core/lib/Thelia/Model/Base/CustomerQuery.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseCustomerQuery.php rename to core/lib/Thelia/Model/Base/CustomerQuery.php index 7f839c024..eb6371592 --- a/core/lib/Thelia/Model/om/BaseCustomerQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerQuery.php @@ -1,177 +1,175 @@ setModelAlias($modelAlias); } @@ -192,21 +190,21 @@ abstract class BaseCustomerQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Customer|Customer[]|mixed the result, formatted by the current formatter + * @return ChildCustomer|array|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 + if ((null !== ($obj = CustomerTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CustomerTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -218,46 +216,31 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Customer A model object, or null if the key is not found - * @throws PropelException + * @return ChildCustomer A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Customer(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCustomer(); $obj->hydrate($row); - CustomerPeer::addInstanceToPool($obj, (string) $key); + CustomerTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -268,19 +251,19 @@ abstract class BaseCustomerQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Customer|Customer[]|mixed the result, formatted by the current formatter + * @return ChildCustomer|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -289,22 +272,22 @@ abstract class BaseCustomerQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Customer[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -312,12 +295,12 @@ abstract class BaseCustomerQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CustomerQuery The current query, for fluid interface + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(CustomerPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(CustomerTableMap::ID, $key, Criteria::EQUAL); } /** @@ -325,12 +308,12 @@ abstract class BaseCustomerQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CustomerQuery The current query, for fluid interface + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(CustomerPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(CustomerTableMap::ID, $keys, Criteria::IN); } /** @@ -340,8 +323,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -350,18 +332,18 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery 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); + $this->addUsingAlias(CustomerTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CustomerPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -372,7 +354,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::ID, $id, $comparison); + return $this->addUsingAlias(CustomerTableMap::ID, $id, $comparison); } /** @@ -388,7 +370,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByRef($ref = null, $comparison = null) { @@ -401,7 +383,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::REF, $ref, $comparison); + return $this->addUsingAlias(CustomerTableMap::REF, $ref, $comparison); } /** @@ -411,8 +393,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $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 + * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12 * * * @see filterByCustomerTitle() @@ -423,18 +404,18 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery 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); + $this->addUsingAlias(CustomerTableMap::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); + $this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -445,7 +426,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); + return $this->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); } /** @@ -461,7 +442,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByCompany($company = null, $comparison = null) { @@ -474,7 +455,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::COMPANY, $company, $comparison); + return $this->addUsingAlias(CustomerTableMap::COMPANY, $company, $comparison); } /** @@ -490,7 +471,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByFirstname($firstname = null, $comparison = null) { @@ -503,7 +484,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::FIRSTNAME, $firstname, $comparison); + return $this->addUsingAlias(CustomerTableMap::FIRSTNAME, $firstname, $comparison); } /** @@ -519,7 +500,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByLastname($lastname = null, $comparison = null) { @@ -532,7 +513,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::LASTNAME, $lastname, $comparison); + return $this->addUsingAlias(CustomerTableMap::LASTNAME, $lastname, $comparison); } /** @@ -548,7 +529,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByAddress1($address1 = null, $comparison = null) { @@ -561,7 +542,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::ADDRESS1, $address1, $comparison); + return $this->addUsingAlias(CustomerTableMap::ADDRESS1, $address1, $comparison); } /** @@ -577,7 +558,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByAddress2($address2 = null, $comparison = null) { @@ -590,7 +571,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::ADDRESS2, $address2, $comparison); + return $this->addUsingAlias(CustomerTableMap::ADDRESS2, $address2, $comparison); } /** @@ -606,7 +587,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByAddress3($address3 = null, $comparison = null) { @@ -619,7 +600,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::ADDRESS3, $address3, $comparison); + return $this->addUsingAlias(CustomerTableMap::ADDRESS3, $address3, $comparison); } /** @@ -635,7 +616,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByZipcode($zipcode = null, $comparison = null) { @@ -648,7 +629,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::ZIPCODE, $zipcode, $comparison); + return $this->addUsingAlias(CustomerTableMap::ZIPCODE, $zipcode, $comparison); } /** @@ -664,7 +645,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByCity($city = null, $comparison = null) { @@ -677,7 +658,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::CITY, $city, $comparison); + return $this->addUsingAlias(CustomerTableMap::CITY, $city, $comparison); } /** @@ -687,8 +668,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $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 + * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 * * * @param mixed $countryId The value to use as filter. @@ -697,18 +677,18 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery 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); + $this->addUsingAlias(CustomerTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($countryId['max'])) { - $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -719,7 +699,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId, $comparison); + return $this->addUsingAlias(CustomerTableMap::COUNTRY_ID, $countryId, $comparison); } /** @@ -735,7 +715,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByPhone($phone = null, $comparison = null) { @@ -748,7 +728,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::PHONE, $phone, $comparison); + return $this->addUsingAlias(CustomerTableMap::PHONE, $phone, $comparison); } /** @@ -764,7 +744,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByCellphone($cellphone = null, $comparison = null) { @@ -777,7 +757,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::CELLPHONE, $cellphone, $comparison); + return $this->addUsingAlias(CustomerTableMap::CELLPHONE, $cellphone, $comparison); } /** @@ -793,7 +773,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByEmail($email = null, $comparison = null) { @@ -806,7 +786,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::EMAIL, $email, $comparison); + return $this->addUsingAlias(CustomerTableMap::EMAIL, $email, $comparison); } /** @@ -822,7 +802,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByPassword($password = null, $comparison = null) { @@ -835,7 +815,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::PASSWORD, $password, $comparison); + return $this->addUsingAlias(CustomerTableMap::PASSWORD, $password, $comparison); } /** @@ -851,7 +831,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByAlgo($algo = null, $comparison = null) { @@ -864,7 +844,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::ALGO, $algo, $comparison); + return $this->addUsingAlias(CustomerTableMap::ALGO, $algo, $comparison); } /** @@ -880,7 +860,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterBySalt($salt = null, $comparison = null) { @@ -893,7 +873,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::SALT, $salt, $comparison); + return $this->addUsingAlias(CustomerTableMap::SALT, $salt, $comparison); } /** @@ -903,8 +883,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $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 + * $query->filterByReseller(array('min' => 12)); // WHERE reseller > 12 * * * @param mixed $reseller The value to use as filter. @@ -913,18 +892,18 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery 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); + $this->addUsingAlias(CustomerTableMap::RESELLER, $reseller['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($reseller['max'])) { - $this->addUsingAlias(CustomerPeer::RESELLER, $reseller['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTableMap::RESELLER, $reseller['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -935,7 +914,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::RESELLER, $reseller, $comparison); + return $this->addUsingAlias(CustomerTableMap::RESELLER, $reseller, $comparison); } /** @@ -951,7 +930,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByLang($lang = null, $comparison = null) { @@ -964,7 +943,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::LANG, $lang, $comparison); + return $this->addUsingAlias(CustomerTableMap::LANG, $lang, $comparison); } /** @@ -980,7 +959,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterBySponsor($sponsor = null, $comparison = null) { @@ -993,7 +972,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::SPONSOR, $sponsor, $comparison); + return $this->addUsingAlias(CustomerTableMap::SPONSOR, $sponsor, $comparison); } /** @@ -1003,8 +982,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * * $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 + * $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12 * * * @param mixed $discount The value to use as filter. @@ -1013,18 +991,18 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery 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); + $this->addUsingAlias(CustomerTableMap::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($discount['max'])) { - $this->addUsingAlias(CustomerPeer::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTableMap::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -1035,7 +1013,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::DISCOUNT, $discount, $comparison); + return $this->addUsingAlias(CustomerTableMap::DISCOUNT, $discount, $comparison); } /** @@ -1056,18 +1034,18 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery 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); + $this->addUsingAlias(CustomerTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CustomerPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -1078,7 +1056,7 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CustomerTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -1099,18 +1077,18 @@ abstract class BaseCustomerQuery extends ModelCriteria * 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 + * @return ChildCustomerQuery 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); + $this->addUsingAlias(CustomerTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CustomerPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -1121,32 +1099,31 @@ abstract class BaseCustomerQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CustomerTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related CustomerTitle object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\CustomerTitle|ObjectCollection $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. + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByCustomerTitle($customerTitle, $comparison = null) { - if ($customerTitle instanceof CustomerTitle) { + if ($customerTitle instanceof \Thelia\Model\CustomerTitle) { return $this - ->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison); - } elseif ($customerTitle instanceof PropelObjectCollection) { + ->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison); + } elseif ($customerTitle instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(CustomerTableMap::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection'); + throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection'); } } @@ -1156,7 +1133,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * @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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1185,7 +1162,7 @@ abstract class BaseCustomerQuery extends ModelCriteria /** * Use the CustomerTitle relation CustomerTitle object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1201,26 +1178,25 @@ abstract class BaseCustomerQuery extends ModelCriteria } /** - * Filter the query by a related Address object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Address|ObjectCollection $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. + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByAddress($address, $comparison = null) { - if ($address instanceof Address) { + if ($address instanceof \Thelia\Model\Address) { return $this - ->addUsingAlias(CustomerPeer::ID, $address->getCustomerId(), $comparison); - } elseif ($address instanceof PropelObjectCollection) { + ->addUsingAlias(CustomerTableMap::ID, $address->getCustomerId(), $comparison); + } elseif ($address instanceof ObjectCollection) { return $this ->useAddressQuery() ->filterByPrimaryKeys($address->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection'); + throw new PropelException('filterByAddress() only accepts arguments of type \Thelia\Model\Address or Collection'); } } @@ -1230,7 +1206,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * @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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function joinAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1259,7 +1235,7 @@ abstract class BaseCustomerQuery extends ModelCriteria /** * Use the Address relation Address object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1275,26 +1251,25 @@ abstract class BaseCustomerQuery extends ModelCriteria } /** - * Filter the query by a related Order object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Order|ObjectCollection $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. + * @return ChildCustomerQuery The current query, for fluid interface */ public function filterByOrder($order, $comparison = null) { - if ($order instanceof Order) { + if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(CustomerPeer::ID, $order->getCustomerId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { + ->addUsingAlias(CustomerTableMap::ID, $order->getCustomerId(), $comparison); + } elseif ($order instanceof ObjectCollection) { return $this ->useOrderQuery() ->filterByPrimaryKeys($order->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); + throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); } } @@ -1304,7 +1279,7 @@ abstract class BaseCustomerQuery extends ModelCriteria * @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 + * @return ChildCustomerQuery The current query, for fluid interface */ public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1333,7 +1308,7 @@ abstract class BaseCustomerQuery extends ModelCriteria /** * Use the Order relation Order object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1351,19 +1326,94 @@ abstract class BaseCustomerQuery extends ModelCriteria /** * Exclude object from result * - * @param Customer $customer Object to remove from the list of results + * @param ChildCustomer $customer Object to remove from the list of results * - * @return CustomerQuery The current query, for fluid interface + * @return ChildCustomerQuery The current query, for fluid interface */ public function prune($customer = null) { if ($customer) { - $this->addUsingAlias(CustomerPeer::ID, $customer->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(CustomerTableMap::ID, $customer->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the customer table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CustomerTableMap::clearInstancePool(); + CustomerTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCustomer or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCustomer object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CustomerTableMap::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(); + + + CustomerTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CustomerTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -1371,31 +1421,11 @@ abstract class BaseCustomerQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return CustomerQuery The current query, for fluid interface + * @return ChildCustomerQuery 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); + return $this->addUsingAlias(CustomerTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -1403,30 +1433,51 @@ abstract class BaseCustomerQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return CustomerQuery The current query, for fluid interface + * @return ChildCustomerQuery 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); + return $this->addUsingAlias(CustomerTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCustomerQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CustomerTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCustomerQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CustomerTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return CustomerQuery The current query, for fluid interface + * @return ChildCustomerQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(CustomerPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(CustomerTableMap::CREATED_AT); } /** * Order by create date asc * - * @return CustomerQuery The current query, for fluid interface + * @return ChildCustomerQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(CustomerPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(CustomerTableMap::CREATED_AT); } -} + +} // CustomerQuery diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseCustomerTitle.php rename to core/lib/Thelia/Model/Base/CustomerTitle.php index 3d1967579..c060f7fae --- a/core/lib/Thelia/Model/om/BaseCustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -1,57 +1,65 @@ applyDefaultValues(); } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CustomerTitle instance. If + * obj is an instance of CustomerTitle, delegates to + * equals(CustomerTitle). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CustomerTitle The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CustomerTitle The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [by_default] column value. * - * @return int + * @return int */ public function getByDefault() { + return $this->by_default; } /** * Get the [position] column value. * - * @return string + * @return string */ public function getPosition() { + return $this->position; } @@ -209,97 +454,57 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = CustomerTitlePeer::ID; + $this->modifiedColumns[] = CustomerTitleTableMap::ID; } @@ -309,18 +514,18 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Set the value of [by_default] column. * - * @param int $v new value - * @return CustomerTitle The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) */ public function setByDefault($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->by_default !== $v) { $this->by_default = $v; - $this->modifiedColumns[] = CustomerTitlePeer::BY_DEFAULT; + $this->modifiedColumns[] = CustomerTitleTableMap::BY_DEFAULT; } @@ -330,18 +535,18 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param string $v new value - * @return CustomerTitle The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = CustomerTitlePeer::POSITION; + $this->modifiedColumns[] = CustomerTitleTableMap::POSITION; } @@ -351,19 +556,17 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = CustomerTitleTableMap::CREATED_AT; } } // if either are not null @@ -374,19 +577,17 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = CustomerTitleTableMap::UPDATED_AT; } } // if either are not null @@ -408,7 +609,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent return false; } - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -420,21 +621,41 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerTitleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerTitleTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->by_default = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTitleTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTitleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CustomerTitleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -442,11 +663,11 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = CustomerTitlePeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 5; // 5 = CustomerTitleTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating CustomerTitle object", $e); + throw new PropelException("Error populating \Thelia\Model\CustomerTitle object", 0, $e); } } @@ -465,7 +686,6 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -473,12 +693,12 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -489,25 +709,25 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CustomerTitleTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildCustomerTitleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? $this->collCustomers = null; - $this->collAddresss = null; + $this->collAddresses = null; $this->collCustomerTitleI18ns = null; @@ -517,26 +737,25 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see CustomerTitle::setDeleted() + * @see CustomerTitle::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = CustomerTitleQuery::create() + $deleteQuery = ChildCustomerTitleQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -561,20 +780,19 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -584,16 +802,16 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(CustomerTitlePeer::CREATED_AT)) { + if (!$this->isColumnModified(CustomerTitleTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) { + if (!$this->isColumnModified(CustomerTitleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(CustomerTitleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -605,7 +823,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - CustomerTitlePeer::addInstanceToPool($this); + CustomerTitleTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -624,12 +842,12 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -656,26 +874,26 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } } - if ($this->collCustomers !== null) { - foreach ($this->collCustomers as $referrerFK) { + 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) { + if ($this->addressesScheduledForDeletion !== null) { + if (!$this->addressesScheduledForDeletion->isEmpty()) { + foreach ($this->addressesScheduledForDeletion as $address) { // need to save related object because we set the relation to null $address->save($con); } - $this->addresssScheduledForDeletion = null; + $this->addressesScheduledForDeletion = null; } } - if ($this->collAddresss !== null) { - foreach ($this->collAddresss as $referrerFK) { + if ($this->collAddresses !== null) { + foreach ($this->collAddresses as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -684,15 +902,15 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if ($this->customerTitleI18nsScheduledForDeletion !== null) { if (!$this->customerTitleI18nsScheduledForDeletion->isEmpty()) { - CustomerTitleI18nQuery::create() + \Thelia\Model\CustomerTitleI18nQuery::create() ->filterByPrimaryKeys($this->customerTitleI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->customerTitleI18nsScheduledForDeletion = null; } } - if ($this->collCustomerTitleI18ns !== null) { - foreach ($this->collCustomerTitleI18ns as $referrerFK) { + if ($this->collCustomerTitleI18ns !== null) { + foreach ($this->collCustomerTitleI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -709,40 +927,40 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = CustomerTitlePeer::ID; + $this->modifiedColumns[] = CustomerTitleTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerTitlePeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerTitleTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CustomerTitlePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(CustomerTitleTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(CustomerTitlePeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`by_default`'; + if ($this->isColumnModified(CustomerTitleTableMap::BY_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'BY_DEFAULT'; } - if ($this->isColumnModified(CustomerTitlePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(CustomerTitleTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(CustomerTitlePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(CustomerTitleTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(CustomerTitleTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `customer_title` (%s) VALUES (%s)', + 'INSERT INTO customer_title (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -751,33 +969,33 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`by_default`': + case 'BY_DEFAULT': $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -787,128 +1005,32 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = CustomerTitlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CustomerTitleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -918,7 +1040,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -951,22 +1073,22 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = CustomerTitleTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getByDefault(), @@ -974,12 +1096,18 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + 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->collAddresses) { + $result['Addresses'] = $this->collAddresses->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collCustomerTitleI18ns) { $result['CustomerTitleI18ns'] = $this->collCustomerTitleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -992,27 +1120,27 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = CustomerTitlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = CustomerTitleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1045,17 +1173,17 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = CustomerTitlePeer::getFieldNames($keyType); + $keys = CustomerTitleTableMap::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]]); @@ -1071,13 +1199,13 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME); + $criteria = new Criteria(CustomerTitleTableMap::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); + if ($this->isColumnModified(CustomerTitleTableMap::ID)) $criteria->add(CustomerTitleTableMap::ID, $this->id); + if ($this->isColumnModified(CustomerTitleTableMap::BY_DEFAULT)) $criteria->add(CustomerTitleTableMap::BY_DEFAULT, $this->by_default); + if ($this->isColumnModified(CustomerTitleTableMap::POSITION)) $criteria->add(CustomerTitleTableMap::POSITION, $this->position); + if ($this->isColumnModified(CustomerTitleTableMap::CREATED_AT)) $criteria->add(CustomerTitleTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CustomerTitleTableMap::UPDATED_AT)) $criteria->add(CustomerTitleTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1092,15 +1220,15 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME); - $criteria->add(CustomerTitlePeer::ID, $this->id); + $criteria = new Criteria(CustomerTitleTableMap::DATABASE_NAME); + $criteria->add(CustomerTitleTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1110,7 +1238,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1134,9 +1262,9 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1146,12 +1274,10 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1159,7 +1285,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } } - foreach ($this->getAddresss() as $relObj) { + foreach ($this->getAddresses() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addAddress($relObj->copy($deepCopy)); } @@ -1171,8 +1297,6 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1189,8 +1313,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\CustomerTitle Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1203,43 +1327,25 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('Customer' == $relationName) { - $this->initCustomers(); + return $this->initCustomers(); } if ('Address' == $relationName) { - $this->initAddresss(); + return $this->initAddresses(); } if ('CustomerTitleI18n' == $relationName) { - $this->initCustomerTitleI18ns(); + return $this->initCustomerTitleI18ns(); } } @@ -1249,21 +1355,16 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * This 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) + * @return void * @see addCustomers() */ public function clearCustomers() { - $this->collCustomers = null; // important to set this to null since that means it is uninitialized - $this->collCustomersPartial = null; - - return $this; + $this->collCustomers = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collCustomers collection loaded partially - * - * @return void + * Reset is the collCustomers collection loaded partially. */ public function resetPartialCustomers($v = true) { @@ -1277,7 +1378,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1287,25 +1388,25 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if (null !== $this->collCustomers && !$overrideExisting) { return; } - $this->collCustomers = new PropelObjectCollection(); - $this->collCustomers->setModel('Customer'); + $this->collCustomers = new ObjectCollection(); + $this->collCustomers->setModel('\Thelia\Model\Customer'); } /** - * Gets an array of Customer objects which contain a foreign key that references this object. + * Gets an array of ChildCustomer objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCustomerTitle is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCustomer[] List of ChildCustomer objects * @throws PropelException */ - public function getCustomers($criteria = null, PropelPDO $con = null) + public function getCustomers($criteria = null, ConnectionInterface $con = null) { $partial = $this->collCustomersPartial && !$this->isNew(); if (null === $this->collCustomers || null !== $criteria || $partial) { @@ -1313,29 +1414,31 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent // return empty collection $this->initCustomers(); } else { - $collCustomers = CustomerQuery::create(null, $criteria) + $collCustomers = ChildCustomerQuery::create(null, $criteria) ->filterByCustomerTitle($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collCustomersPartial && count($collCustomers)) { - $this->initCustomers(false); + $this->initCustomers(false); - foreach($collCustomers as $obj) { - if (false == $this->collCustomers->contains($obj)) { - $this->collCustomers->append($obj); + foreach ($collCustomers as $obj) { + if (false == $this->collCustomers->contains($obj)) { + $this->collCustomers->append($obj); + } } - } - $this->collCustomersPartial = true; + $this->collCustomersPartial = true; } $collCustomers->getInternalIterator()->rewind(); + return $collCustomers; } - if($partial && $this->collCustomers) { - foreach($this->collCustomers as $obj) { - if($obj->isNew()) { + if ($partial && $this->collCustomers) { + foreach ($this->collCustomers as $obj) { + if ($obj->isNew()) { $collCustomers[] = $obj; } } @@ -1355,15 +1458,16 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * It will 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) + * @param Collection $customers A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCustomerTitle The current object (for fluent API support) */ - public function setCustomers(PropelCollection $customers, PropelPDO $con = null) + public function setCustomers(Collection $customers, ConnectionInterface $con = null) { $customersToDelete = $this->getCustomers(new Criteria(), $con)->diff($customers); - $this->customersScheduledForDeletion = unserialize(serialize($customersToDelete)); + + $this->customersScheduledForDeletion = $customersToDelete; foreach ($customersToDelete as $customerRemoved) { $customerRemoved->setCustomerTitle(null); @@ -1383,13 +1487,13 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Returns the number of related Customer objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Customer objects. * @throws PropelException */ - public function countCustomers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countCustomers(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collCustomersPartial && !$this->isNew(); if (null === $this->collCustomers || null !== $criteria || $partial) { @@ -1397,10 +1501,11 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getCustomers()); } - $query = CustomerQuery::create(null, $criteria); + + $query = ChildCustomerQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1414,18 +1519,19 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } /** - * Method called to associate a Customer object to this object - * through the Customer foreign key attribute. + * Method called to associate a ChildCustomer object to this object + * through the ChildCustomer foreign key attribute. * - * @param Customer $l Customer - * @return CustomerTitle The current object (for fluent API support) + * @param ChildCustomer $l ChildCustomer + * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) */ - public function addCustomer(Customer $l) + public function addCustomer(ChildCustomer $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); } @@ -1434,7 +1540,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } /** - * @param Customer $customer The customer object to add. + * @param Customer $customer The customer object to add. */ protected function doAddCustomer($customer) { @@ -1443,8 +1549,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } /** - * @param Customer $customer The customer object to remove. - * @return CustomerTitle The current object (for fluent API support) + * @param Customer $customer The customer object to remove. + * @return ChildCustomerTitle The current object (for fluent API support) */ public function removeCustomer($customer) { @@ -1462,109 +1568,106 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } /** - * Clears out the collAddresss collection + * Clears out the collAddresses collection * * This 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 + * @see addAddresses() */ - public function resetPartialAddresss($v = true) + public function clearAddresses() { - $this->collAddresssPartial = $v; + $this->collAddresses = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collAddresss collection. + * Reset is the collAddresses collection loaded partially. + */ + public function resetPartialAddresses($v = true) + { + $this->collAddressesPartial = $v; + } + + /** + * Initializes the collAddresses collection. * - * By default this just sets the collAddresss collection to an empty array (like clearcollAddresss()); + * By default this just sets the collAddresses collection to an empty array (like clearcollAddresses()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initAddresses($overrideExisting = true) { - if (null !== $this->collAddresss && !$overrideExisting) { + if (null !== $this->collAddresses && !$overrideExisting) { return; } - $this->collAddresss = new PropelObjectCollection(); - $this->collAddresss->setModel('Address'); + $this->collAddresses = new ObjectCollection(); + $this->collAddresses->setModel('\Thelia\Model\Address'); } /** - * Gets an array of Address objects which contain a foreign key that references this object. + * Gets an array of ChildAddress objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCustomerTitle is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAddress[] List of ChildAddress objects * @throws PropelException */ - public function getAddresss($criteria = null, PropelPDO $con = null) + public function getAddresses($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collAddresssPartial && !$this->isNew(); - if (null === $this->collAddresss || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAddresss) { + $partial = $this->collAddressesPartial && !$this->isNew(); + if (null === $this->collAddresses || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAddresses) { // return empty collection - $this->initAddresss(); + $this->initAddresses(); } else { - $collAddresss = AddressQuery::create(null, $criteria) + $collAddresses = ChildAddressQuery::create(null, $criteria) ->filterByCustomerTitle($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collAddresssPartial && count($collAddresss)) { - $this->initAddresss(false); + if (false !== $this->collAddressesPartial && count($collAddresses)) { + $this->initAddresses(false); - foreach($collAddresss as $obj) { - if (false == $this->collAddresss->contains($obj)) { - $this->collAddresss->append($obj); + foreach ($collAddresses as $obj) { + if (false == $this->collAddresses->contains($obj)) { + $this->collAddresses->append($obj); + } } - } - $this->collAddresssPartial = true; + $this->collAddressesPartial = true; } - $collAddresss->getInternalIterator()->rewind(); - return $collAddresss; + $collAddresses->getInternalIterator()->rewind(); + + return $collAddresses; } - if($partial && $this->collAddresss) { - foreach($this->collAddresss as $obj) { - if($obj->isNew()) { - $collAddresss[] = $obj; + if ($partial && $this->collAddresses) { + foreach ($this->collAddresses as $obj) { + if ($obj->isNew()) { + $collAddresses[] = $obj; } } } - $this->collAddresss = $collAddresss; - $this->collAddresssPartial = false; + $this->collAddresses = $collAddresses; + $this->collAddressesPartial = false; } } - return $this->collAddresss; + return $this->collAddresses; } /** @@ -1573,27 +1676,28 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * It will 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) + * @param Collection $addresses A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCustomerTitle The current object (for fluent API support) */ - public function setAddresss(PropelCollection $addresss, PropelPDO $con = null) + public function setAddresses(Collection $addresses, ConnectionInterface $con = null) { - $addresssToDelete = $this->getAddresss(new Criteria(), $con)->diff($addresss); + $addressesToDelete = $this->getAddresses(new Criteria(), $con)->diff($addresses); - $this->addresssScheduledForDeletion = unserialize(serialize($addresssToDelete)); - foreach ($addresssToDelete as $addressRemoved) { + $this->addressesScheduledForDeletion = $addressesToDelete; + + foreach ($addressesToDelete as $addressRemoved) { $addressRemoved->setCustomerTitle(null); } - $this->collAddresss = null; - foreach ($addresss as $address) { + $this->collAddresses = null; + foreach ($addresses as $address) { $this->addAddress($address); } - $this->collAddresss = $addresss; - $this->collAddresssPartial = false; + $this->collAddresses = $addresses; + $this->collAddressesPartial = false; return $this; } @@ -1601,24 +1705,25 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Returns the number of related Address objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Address objects. * @throws PropelException */ - public function countAddresss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAddresses(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collAddresssPartial && !$this->isNew(); - if (null === $this->collAddresss || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAddresss) { + $partial = $this->collAddressesPartial && !$this->isNew(); + if (null === $this->collAddresses || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAddresses) { return 0; } - if($partial && !$criteria) { - return count($this->getAddresss()); + if ($partial && !$criteria) { + return count($this->getAddresses()); } - $query = AddressQuery::create(null, $criteria); + + $query = ChildAddressQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1628,23 +1733,24 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent ->count($con); } - return count($this->collAddresss); + return count($this->collAddresses); } /** - * Method called to associate a Address object to this object - * through the Address foreign key attribute. + * Method called to associate a ChildAddress object to this object + * through the ChildAddress foreign key attribute. * - * @param Address $l Address - * @return CustomerTitle The current object (for fluent API support) + * @param ChildAddress $l ChildAddress + * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) */ - public function addAddress(Address $l) + public function addAddress(ChildAddress $l) { - if ($this->collAddresss === null) { - $this->initAddresss(); - $this->collAddresssPartial = true; + if ($this->collAddresses === null) { + $this->initAddresses(); + $this->collAddressesPartial = true; } - if (!in_array($l, $this->collAddresss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collAddresses->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAddress($l); } @@ -1652,27 +1758,27 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } /** - * @param Address $address The address object to add. + * @param Address $address The address object to add. */ protected function doAddAddress($address) { - $this->collAddresss[]= $address; + $this->collAddresses[]= $address; $address->setCustomerTitle($this); } /** - * @param Address $address The address object to remove. - * @return CustomerTitle The current object (for fluent API support) + * @param Address $address The address object to remove. + * @return ChildCustomerTitle 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(); + if ($this->getAddresses()->contains($address)) { + $this->collAddresses->remove($this->collAddresses->search($address)); + if (null === $this->addressesScheduledForDeletion) { + $this->addressesScheduledForDeletion = clone $this->collAddresses; + $this->addressesScheduledForDeletion->clear(); } - $this->addresssScheduledForDeletion[]= $address; + $this->addressesScheduledForDeletion[]= $address; $address->setCustomerTitle(null); } @@ -1685,23 +1791,23 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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. + * been saved, it will retrieve related Addresses from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAddress[] List of ChildAddress objects */ - public function getAddresssJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAddressesJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AddressQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); + $query = ChildAddressQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); - return $this->getAddresss($query, $con); + return $this->getAddresses($query, $con); } /** @@ -1710,21 +1816,16 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collCustomerTitleI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collCustomerTitleI18ns collection loaded partially - * - * @return void + * Reset is the collCustomerTitleI18ns collection loaded partially. */ public function resetPartialCustomerTitleI18ns($v = true) { @@ -1738,7 +1839,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1748,25 +1849,25 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent if (null !== $this->collCustomerTitleI18ns && !$overrideExisting) { return; } - $this->collCustomerTitleI18ns = new PropelObjectCollection(); - $this->collCustomerTitleI18ns->setModel('CustomerTitleI18n'); + $this->collCustomerTitleI18ns = new ObjectCollection(); + $this->collCustomerTitleI18ns->setModel('\Thelia\Model\CustomerTitleI18n'); } /** - * Gets an array of CustomerTitleI18n objects which contain a foreign key that references this object. + * Gets an array of ChildCustomerTitleI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildCustomerTitle is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCustomerTitleI18n[] List of ChildCustomerTitleI18n objects * @throws PropelException */ - public function getCustomerTitleI18ns($criteria = null, PropelPDO $con = null) + public function getCustomerTitleI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collCustomerTitleI18nsPartial && !$this->isNew(); if (null === $this->collCustomerTitleI18ns || null !== $criteria || $partial) { @@ -1774,29 +1875,31 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent // return empty collection $this->initCustomerTitleI18ns(); } else { - $collCustomerTitleI18ns = CustomerTitleI18nQuery::create(null, $criteria) + $collCustomerTitleI18ns = ChildCustomerTitleI18nQuery::create(null, $criteria) ->filterByCustomerTitle($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collCustomerTitleI18nsPartial && count($collCustomerTitleI18ns)) { - $this->initCustomerTitleI18ns(false); + $this->initCustomerTitleI18ns(false); - foreach($collCustomerTitleI18ns as $obj) { - if (false == $this->collCustomerTitleI18ns->contains($obj)) { - $this->collCustomerTitleI18ns->append($obj); + foreach ($collCustomerTitleI18ns as $obj) { + if (false == $this->collCustomerTitleI18ns->contains($obj)) { + $this->collCustomerTitleI18ns->append($obj); + } } - } - $this->collCustomerTitleI18nsPartial = true; + $this->collCustomerTitleI18nsPartial = true; } $collCustomerTitleI18ns->getInternalIterator()->rewind(); + return $collCustomerTitleI18ns; } - if($partial && $this->collCustomerTitleI18ns) { - foreach($this->collCustomerTitleI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collCustomerTitleI18ns) { + foreach ($this->collCustomerTitleI18ns as $obj) { + if ($obj->isNew()) { $collCustomerTitleI18ns[] = $obj; } } @@ -1816,15 +1919,19 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * It will 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) + * @param Collection $customerTitleI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildCustomerTitle The current object (for fluent API support) */ - public function setCustomerTitleI18ns(PropelCollection $customerTitleI18ns, PropelPDO $con = null) + public function setCustomerTitleI18ns(Collection $customerTitleI18ns, ConnectionInterface $con = null) { $customerTitleI18nsToDelete = $this->getCustomerTitleI18ns(new Criteria(), $con)->diff($customerTitleI18ns); - $this->customerTitleI18nsScheduledForDeletion = unserialize(serialize($customerTitleI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->customerTitleI18nsScheduledForDeletion = clone $customerTitleI18nsToDelete; foreach ($customerTitleI18nsToDelete as $customerTitleI18nRemoved) { $customerTitleI18nRemoved->setCustomerTitle(null); @@ -1844,13 +1951,13 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Returns the number of related CustomerTitleI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related CustomerTitleI18n objects. * @throws PropelException */ - public function countCustomerTitleI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countCustomerTitleI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collCustomerTitleI18nsPartial && !$this->isNew(); if (null === $this->collCustomerTitleI18ns || null !== $criteria || $partial) { @@ -1858,10 +1965,11 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getCustomerTitleI18ns()); } - $query = CustomerTitleI18nQuery::create(null, $criteria); + + $query = ChildCustomerTitleI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1875,13 +1983,13 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } /** - * Method called to associate a CustomerTitleI18n object to this object - * through the CustomerTitleI18n foreign key attribute. + * Method called to associate a ChildCustomerTitleI18n object to this object + * through the ChildCustomerTitleI18n foreign key attribute. * - * @param CustomerTitleI18n $l CustomerTitleI18n - * @return CustomerTitle The current object (for fluent API support) + * @param ChildCustomerTitleI18n $l ChildCustomerTitleI18n + * @return \Thelia\Model\CustomerTitle The current object (for fluent API support) */ - public function addCustomerTitleI18n(CustomerTitleI18n $l) + public function addCustomerTitleI18n(ChildCustomerTitleI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1891,6 +1999,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $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); } @@ -1899,7 +2008,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } /** - * @param CustomerTitleI18n $customerTitleI18n The customerTitleI18n object to add. + * @param CustomerTitleI18n $customerTitleI18n The customerTitleI18n object to add. */ protected function doAddCustomerTitleI18n($customerTitleI18n) { @@ -1908,8 +2017,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } /** - * @param CustomerTitleI18n $customerTitleI18n The customerTitleI18n object to remove. - * @return CustomerTitle The current object (for fluent API support) + * @param CustomerTitleI18n $customerTitleI18n The customerTitleI18n object to remove. + * @return ChildCustomerTitle The current object (for fluent API support) */ public function removeCustomerTitleI18n($customerTitleI18n) { @@ -1937,8 +2046,6 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -1951,21 +2058,20 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collCustomers) { foreach ($this->collCustomers as $o) { $o->clearAllReferences($deep); } } - if ($this->collAddresss) { - foreach ($this->collAddresss as $o) { + if ($this->collAddresses) { + foreach ($this->collAddresses as $o) { $o->clearAllReferences($deep); } } @@ -1974,46 +2080,34 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collCustomers instanceof PropelCollection) { + if ($this->collCustomers instanceof Collection) { $this->collCustomers->clearIterator(); } $this->collCustomers = null; - if ($this->collAddresss instanceof PropelCollection) { - $this->collAddresss->clearIterator(); + if ($this->collAddresses instanceof Collection) { + $this->collAddresses->clearIterator(); } - $this->collAddresss = null; - if ($this->collCustomerTitleI18ns instanceof PropelCollection) { + $this->collAddresses = null; + if ($this->collCustomerTitleI18ns instanceof Collection) { $this->collCustomerTitleI18ns->clearIterator(); } $this->collCustomerTitleI18ns = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(CustomerTitleTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2021,11 +2115,11 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * 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) + * @return ChildCustomerTitle The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = CustomerTitlePeer::UPDATED_AT; + $this->modifiedColumns[] = CustomerTitleTableMap::UPDATED_AT; return $this; } @@ -2037,9 +2131,9 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return CustomerTitle The current object (for fluent API support) + * @return ChildCustomerTitle The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2060,10 +2154,10 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return CustomerTitleI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildCustomerTitleI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCustomerTitleI18ns) { @@ -2076,10 +2170,10 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new CustomerTitleI18n(); + $translation = new ChildCustomerTitleI18n(); $translation->setLocale($locale); } else { - $translation = CustomerTitleI18nQuery::create() + $translation = ChildCustomerTitleI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -2094,14 +2188,14 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return CustomerTitle The current object (for fluent API support) + * @return ChildCustomerTitle The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - CustomerTitleI18nQuery::create() + ChildCustomerTitleI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -2121,10 +2215,10 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return CustomerTitleI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildCustomerTitleI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -2133,7 +2227,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Get the [short] column value. * - * @return string + * @return string */ public function getShort() { @@ -2144,8 +2238,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Set the value of [short] column. * - * @param string $v new value - * @return CustomerTitleI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support) */ public function setShort($v) { $this->getCurrentTranslation()->setShort($v); @@ -2157,7 +2251,7 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Get the [long] column value. * - * @return string + * @return string */ public function getLong() { @@ -2168,8 +2262,8 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent /** * Set the value of [long] column. * - * @param string $v new value - * @return CustomerTitleI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support) */ public function setLong($v) { $this->getCurrentTranslation()->setLong($v); @@ -2177,4 +2271,122 @@ abstract class BaseCustomerTitle extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php new file mode 100644 index 000000000..38e47ecda --- /dev/null +++ b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php @@ -0,0 +1,1323 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\CustomerTitleI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another CustomerTitleI18n instance. If + * obj is an instance of CustomerTitleI18n, delegates to + * equals(CustomerTitleI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return CustomerTitleI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return CustomerTitleI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\CustomerTitleI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = CustomerTitleI18nTableMap::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 \Thelia\Model\CustomerTitleI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = CustomerTitleI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [short] column. + * + * @param string $v new value + * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support) + */ + public function setShort($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->short !== $v) { + $this->short = $v; + $this->modifiedColumns[] = CustomerTitleI18nTableMap::SHORT; + } + + + return $this; + } // setShort() + + /** + * Set the value of [long] column. + * + * @param string $v new value + * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support) + */ + public function setLong($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->long !== $v) { + $this->long = $v; + $this->modifiedColumns[] = CustomerTitleI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerTitleI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerTitleI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CustomerTitleI18nTableMap::translateFieldName('Short', TableMap::TYPE_PHPNAME, $indexType)]; + $this->short = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CustomerTitleI18nTableMap::translateFieldName('Long', TableMap::TYPE_PHPNAME, $indexType)]; + $this->long = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = CustomerTitleI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\CustomerTitleI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(CustomerTitleI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildCustomerTitleI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aCustomerTitle = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see CustomerTitleI18n::setDeleted() + * @see CustomerTitleI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildCustomerTitleI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME); + } + + $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); + CustomerTitleI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(CustomerTitleI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(CustomerTitleI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(CustomerTitleI18nTableMap::SHORT)) { + $modifiedColumns[':p' . $index++] = 'SHORT'; + } + if ($this->isColumnModified(CustomerTitleI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = CustomerTitleI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['CustomerTitleI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['CustomerTitleI18n'][serialize($this->getPrimaryKey())] = true; + $keys = CustomerTitleI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getShort(), + $keys[3] => $this->getLong(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = CustomerTitleI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = CustomerTitleI18nTableMap::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(CustomerTitleI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(CustomerTitleI18nTableMap::ID)) $criteria->add(CustomerTitleI18nTableMap::ID, $this->id); + if ($this->isColumnModified(CustomerTitleI18nTableMap::LOCALE)) $criteria->add(CustomerTitleI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(CustomerTitleI18nTableMap::SHORT)) $criteria->add(CustomerTitleI18nTableMap::SHORT, $this->short); + if ($this->isColumnModified(CustomerTitleI18nTableMap::LONG)) $criteria->add(CustomerTitleI18nTableMap::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(CustomerTitleI18nTableMap::DATABASE_NAME); + $criteria->add(CustomerTitleI18nTableMap::ID, $this->id); + $criteria->add(CustomerTitleI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildCustomerTitle object. + * + * @param ChildCustomerTitle $v + * @return \Thelia\Model\CustomerTitleI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setCustomerTitle(ChildCustomerTitle $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 ChildCustomerTitle object, it will not be re-added. + if ($v !== null) { + $v->addCustomerTitleI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCustomerTitle object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCustomerTitle The associated ChildCustomerTitle object. + * @throws PropelException + */ + public function getCustomerTitle(ConnectionInterface $con = null) + { + if ($this->aCustomerTitle === null && ($this->id !== null)) { + $this->aCustomerTitle = ChildCustomerTitleQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCustomerTitle = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(CustomerTitleI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18nQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleI18nQuery.php new file mode 100644 index 000000000..4feeab473 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CustomerTitleI18nQuery.php @@ -0,0 +1,541 @@ +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[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCustomerTitleI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CustomerTitleI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CustomerTitleI18nTableMap::DATABASE_NAME); + } + $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 ConnectionInterface $con A connection object + * + * @return ChildCustomerTitleI18n A model object, or null if the key is not found + */ + 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), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCustomerTitleI18n(); + $obj->hydrate($row); + CustomerTitleI18nTableMap::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 ConnectionInterface $con A connection object + * + * @return ChildCustomerTitleI18n|array|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; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * 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 ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCustomerTitleI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(CustomerTitleI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(CustomerTitleI18nTableMap::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 ChildCustomerTitleI18nQuery 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(CustomerTitleI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(CustomerTitleI18nTableMap::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 + * + * + * @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 ChildCustomerTitleI18nQuery 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(CustomerTitleI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CustomerTitleI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CustomerTitleI18nTableMap::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 ChildCustomerTitleI18nQuery 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(CustomerTitleI18nTableMap::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 ChildCustomerTitleI18nQuery 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(CustomerTitleI18nTableMap::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 ChildCustomerTitleI18nQuery 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(CustomerTitleI18nTableMap::LONG, $long, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\CustomerTitle object + * + * @param \Thelia\Model\CustomerTitle|ObjectCollection $customerTitle The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCustomerTitleI18nQuery The current query, for fluid interface + */ + public function filterByCustomerTitle($customerTitle, $comparison = null) + { + if ($customerTitle instanceof \Thelia\Model\CustomerTitle) { + return $this + ->addUsingAlias(CustomerTitleI18nTableMap::ID, $customerTitle->getId(), $comparison); + } elseif ($customerTitle instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CustomerTitleI18nTableMap::ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByCustomerTitle() only accepts arguments of type \Thelia\Model\CustomerTitle or Collection'); + } + } + + /** + * 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 ChildCustomerTitleI18nQuery 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 ChildCustomerTitleI18n $customerTitleI18n Object to remove from the list of results + * + * @return ChildCustomerTitleI18nQuery The current query, for fluid interface + */ + public function prune($customerTitleI18n = null) + { + if ($customerTitleI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(CustomerTitleI18nTableMap::ID), $customerTitleI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(CustomerTitleI18nTableMap::LOCALE), $customerTitleI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the customer_title_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CustomerTitleI18nTableMap::clearInstancePool(); + CustomerTitleI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCustomerTitleI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCustomerTitleI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CustomerTitleI18nTableMap::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(); + + + CustomerTitleI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CustomerTitleI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // CustomerTitleI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php rename to core/lib/Thelia/Model/Base/CustomerTitleQuery.php index d35f91f22..a0b6d7b05 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php @@ -1,101 +1,100 @@ setModelAlias($modelAlias); } @@ -116,21 +115,21 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return CustomerTitle|CustomerTitle[]|mixed the result, formatted by the current formatter + * @return ChildCustomerTitle|array|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 + if ((null !== ($obj = CustomerTitleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(CustomerTitleTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -142,46 +141,31 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return CustomerTitle A model object, or null if the key is not found - * @throws PropelException + * @return ChildCustomerTitle A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `by_default`, `position`, `created_at`, `updated_at` FROM `customer_title` WHERE `id` = :p0'; + $sql = 'SELECT ID, BY_DEFAULT, POSITION, CREATED_AT, UPDATED_AT FROM customer_title WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CustomerTitle(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCustomerTitle(); $obj->hydrate($row); - CustomerTitlePeer::addInstanceToPool($obj, (string) $key); + CustomerTitleTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -192,19 +176,19 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return CustomerTitle|CustomerTitle[]|mixed the result, formatted by the current formatter + * @return ChildCustomerTitle|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -213,22 +197,22 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|CustomerTitle[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -236,12 +220,12 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return CustomerTitleQuery The current query, for fluid interface + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(CustomerTitlePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(CustomerTitleTableMap::ID, $key, Criteria::EQUAL); } /** @@ -249,12 +233,12 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return CustomerTitleQuery The current query, for fluid interface + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(CustomerTitlePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(CustomerTitleTableMap::ID, $keys, Criteria::IN); } /** @@ -264,8 +248,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -274,18 +257,18 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * 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 + * @return ChildCustomerTitleQuery 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); + $this->addUsingAlias(CustomerTitleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(CustomerTitlePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTitleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -296,7 +279,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerTitlePeer::ID, $id, $comparison); + return $this->addUsingAlias(CustomerTitleTableMap::ID, $id, $comparison); } /** @@ -306,8 +289,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * $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 + * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12 * * * @param mixed $byDefault The value to use as filter. @@ -316,18 +298,18 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * 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 + * @return ChildCustomerTitleQuery 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); + $this->addUsingAlias(CustomerTitleTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($byDefault['max'])) { - $this->addUsingAlias(CustomerTitlePeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTitleTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -338,7 +320,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerTitlePeer::BY_DEFAULT, $byDefault, $comparison); + return $this->addUsingAlias(CustomerTitleTableMap::BY_DEFAULT, $byDefault, $comparison); } /** @@ -354,7 +336,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * 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 + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function filterByPosition($position = null, $comparison = null) { @@ -367,7 +349,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerTitlePeer::POSITION, $position, $comparison); + return $this->addUsingAlias(CustomerTitleTableMap::POSITION, $position, $comparison); } /** @@ -388,18 +370,18 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * 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 + * @return ChildCustomerTitleQuery 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); + $this->addUsingAlias(CustomerTitleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTitleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -410,7 +392,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(CustomerTitleTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -431,18 +413,18 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * 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 + * @return ChildCustomerTitleQuery 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); + $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -453,30 +435,29 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } } - return $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Customer object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Customer|ObjectCollection $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. + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function filterByCustomer($customer, $comparison = null) { - if ($customer instanceof Customer) { + if ($customer instanceof \Thelia\Model\Customer) { return $this - ->addUsingAlias(CustomerTitlePeer::ID, $customer->getCustomerTitleId(), $comparison); - } elseif ($customer instanceof PropelObjectCollection) { + ->addUsingAlias(CustomerTitleTableMap::ID, $customer->getCustomerTitleId(), $comparison); + } elseif ($customer instanceof ObjectCollection) { return $this ->useCustomerQuery() ->filterByPrimaryKeys($customer->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection'); + throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection'); } } @@ -486,7 +467,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @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 + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function joinCustomer($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -515,7 +496,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria /** * Use the Customer relation Customer object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -531,26 +512,25 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } /** - * Filter the query by a related Address object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Address|ObjectCollection $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. + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function filterByAddress($address, $comparison = null) { - if ($address instanceof Address) { + if ($address instanceof \Thelia\Model\Address) { return $this - ->addUsingAlias(CustomerTitlePeer::ID, $address->getCustomerTitleId(), $comparison); - } elseif ($address instanceof PropelObjectCollection) { + ->addUsingAlias(CustomerTitleTableMap::ID, $address->getCustomerTitleId(), $comparison); + } elseif ($address instanceof ObjectCollection) { return $this ->useAddressQuery() ->filterByPrimaryKeys($address->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection'); + throw new PropelException('filterByAddress() only accepts arguments of type \Thelia\Model\Address or Collection'); } } @@ -560,7 +540,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @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 + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function joinAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -589,7 +569,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria /** * Use the Address relation Address object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -605,26 +585,25 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria } /** - * Filter the query by a related CustomerTitleI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\CustomerTitleI18n|ObjectCollection $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. + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function filterByCustomerTitleI18n($customerTitleI18n, $comparison = null) { - if ($customerTitleI18n instanceof CustomerTitleI18n) { + if ($customerTitleI18n instanceof \Thelia\Model\CustomerTitleI18n) { return $this - ->addUsingAlias(CustomerTitlePeer::ID, $customerTitleI18n->getId(), $comparison); - } elseif ($customerTitleI18n instanceof PropelObjectCollection) { + ->addUsingAlias(CustomerTitleTableMap::ID, $customerTitleI18n->getId(), $comparison); + } elseif ($customerTitleI18n instanceof ObjectCollection) { return $this ->useCustomerTitleI18nQuery() ->filterByPrimaryKeys($customerTitleI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCustomerTitleI18n() only accepts arguments of type CustomerTitleI18n or PropelCollection'); + throw new PropelException('filterByCustomerTitleI18n() only accepts arguments of type \Thelia\Model\CustomerTitleI18n or Collection'); } } @@ -634,7 +613,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @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 + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function joinCustomerTitleI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -663,7 +642,7 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria /** * Use the CustomerTitleI18n relation CustomerTitleI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -681,19 +660,94 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria /** * Exclude object from result * - * @param CustomerTitle $customerTitle Object to remove from the list of results + * @param ChildCustomerTitle $customerTitle Object to remove from the list of results * - * @return CustomerTitleQuery The current query, for fluid interface + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function prune($customerTitle = null) { if ($customerTitle) { - $this->addUsingAlias(CustomerTitlePeer::ID, $customerTitle->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(CustomerTitleTableMap::ID, $customerTitle->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the customer_title table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + CustomerTitleTableMap::clearInstancePool(); + CustomerTitleTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCustomerTitle or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCustomerTitle object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CustomerTitleTableMap::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(); + + + CustomerTitleTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CustomerTitleTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -701,31 +755,11 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return CustomerTitleQuery The current query, for fluid interface + * @return ChildCustomerTitleQuery 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); + return $this->addUsingAlias(CustomerTitleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -733,32 +767,53 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return CustomerTitleQuery The current query, for fluid interface + * @return ChildCustomerTitleQuery 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); + return $this->addUsingAlias(CustomerTitleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCustomerTitleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CustomerTitleTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCustomerTitleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CustomerTitleTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return CustomerTitleQuery The current query, for fluid interface + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(CustomerTitlePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(CustomerTitleTableMap::CREATED_AT); } /** * Order by create date asc * - * @return CustomerTitleQuery The current query, for fluid interface + * @return ChildCustomerTitleQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(CustomerTitlePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(CustomerTitleTableMap::CREATED_AT); } + // i18n behavior /** @@ -768,9 +823,9 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @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 + * @return ChildCustomerTitleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CustomerTitleI18n'; @@ -786,9 +841,9 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @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 + * @return ChildCustomerTitleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -807,13 +862,13 @@ abstract class BaseCustomerTitleQuery extends ModelCriteria * @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 + * @return ChildCustomerTitleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CustomerTitleI18n', 'Thelia\Model\CustomerTitleI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'CustomerTitleI18n', '\Thelia\Model\CustomerTitleI18nQuery'); } -} +} // CustomerTitleQuery diff --git a/core/lib/Thelia/Model/Base/Delivzone.php b/core/lib/Thelia/Model/Base/Delivzone.php new file mode 100644 index 000000000..08125044e --- /dev/null +++ b/core/lib/Thelia/Model/Base/Delivzone.php @@ -0,0 +1,1418 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Delivzone instance. If + * obj is an instance of Delivzone, delegates to + * equals(Delivzone). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Delivzone The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Delivzone The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\Delivzone The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = DelivzoneTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [area_id] column. + * + * @param int $v new value + * @return \Thelia\Model\Delivzone The current object (for fluent API support) + */ + public function setAreaId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->area_id !== $v) { + $this->area_id = $v; + $this->modifiedColumns[] = DelivzoneTableMap::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 \Thelia\Model\Delivzone The current object (for fluent API support) + */ + public function setDelivery($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->delivery !== $v) { + $this->delivery = $v; + $this->modifiedColumns[] = DelivzoneTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = DelivzoneTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = DelivzoneTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DelivzoneTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DelivzoneTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->area_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DelivzoneTableMap::translateFieldName('Delivery', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DelivzoneTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DelivzoneTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = DelivzoneTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\Delivzone object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(DelivzoneTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildDelivzoneQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aArea = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see Delivzone::setDeleted() + * @see Delivzone::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildDelivzoneQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(DelivzoneTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + DelivzoneTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = DelivzoneTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . DelivzoneTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(DelivzoneTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) { + $modifiedColumns[':p' . $index++] = 'AREA_ID'; + } + if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY'; + } + if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(DelivzoneTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()] = true; + $keys = DelivzoneTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getAreaId(), + $keys[2] => $this->getDelivery(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = DelivzoneTableMap::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(DelivzoneTableMap::DATABASE_NAME); + + if ($this->isColumnModified(DelivzoneTableMap::ID)) $criteria->add(DelivzoneTableMap::ID, $this->id); + if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) $criteria->add(DelivzoneTableMap::AREA_ID, $this->area_id); + if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) $criteria->add(DelivzoneTableMap::DELIVERY, $this->delivery); + if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) $criteria->add(DelivzoneTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) $criteria->add(DelivzoneTableMap::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(DelivzoneTableMap::DATABASE_NAME); + $criteria->add(DelivzoneTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildArea object. + * + * @param ChildArea $v + * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @throws PropelException + */ + public function setArea(ChildArea $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 ChildArea object, it will not be re-added. + if ($v !== null) { + $v->addDelivzone($this); + } + + + return $this; + } + + + /** + * Get the associated ChildArea object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildArea The associated ChildArea object. + * @throws PropelException + */ + public function getArea(ConnectionInterface $con = null) + { + if ($this->aArea === null && ($this->area_id !== null)) { + $this->aArea = ChildAreaQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aArea = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(DelivzoneTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildDelivzone The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = DelivzoneTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php b/core/lib/Thelia/Model/Base/DelivzoneQuery.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseDelivzoneQuery.php rename to core/lib/Thelia/Model/Base/DelivzoneQuery.php index 93f87df2c..e4b8a8ab5 --- a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php +++ b/core/lib/Thelia/Model/Base/DelivzoneQuery.php @@ -1,91 +1,91 @@ setModelAlias($modelAlias); } @@ -106,21 +106,21 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Delivzone|Delivzone[]|mixed the result, formatted by the current formatter + * @return ChildDelivzone|array|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 + if ((null !== ($obj = DelivzoneTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(DelivzoneTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -132,46 +132,31 @@ abstract class BaseDelivzoneQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Delivzone A model object, or null if the key is not found - * @throws PropelException + * @return ChildDelivzone A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `area_id`, `delivery`, `created_at`, `updated_at` FROM `delivzone` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Delivzone(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildDelivzone(); $obj->hydrate($row); - DelivzonePeer::addInstanceToPool($obj, (string) $key); + DelivzoneTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -182,19 +167,19 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Delivzone|Delivzone[]|mixed the result, formatted by the current formatter + * @return ChildDelivzone|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -203,22 +188,22 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Delivzone[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -226,12 +211,12 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return DelivzoneQuery The current query, for fluid interface + * @return ChildDelivzoneQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(DelivzonePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(DelivzoneTableMap::ID, $key, Criteria::EQUAL); } /** @@ -239,12 +224,12 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return DelivzoneQuery The current query, for fluid interface + * @return ChildDelivzoneQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(DelivzonePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(DelivzoneTableMap::ID, $keys, Criteria::IN); } /** @@ -254,8 +239,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -264,18 +248,18 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * 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 + * @return ChildDelivzoneQuery 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); + $this->addUsingAlias(DelivzoneTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(DelivzonePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DelivzoneTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -286,7 +270,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzonePeer::ID, $id, $comparison); + return $this->addUsingAlias(DelivzoneTableMap::ID, $id, $comparison); } /** @@ -296,8 +280,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * * $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 + * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12 * * * @see filterByArea() @@ -308,18 +291,18 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * 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 + * @return ChildDelivzoneQuery 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); + $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($areaId['max'])) { - $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -330,7 +313,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId, $comparison); + return $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId, $comparison); } /** @@ -346,7 +329,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * 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 + * @return ChildDelivzoneQuery The current query, for fluid interface */ public function filterByDelivery($delivery = null, $comparison = null) { @@ -359,7 +342,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzonePeer::DELIVERY, $delivery, $comparison); + return $this->addUsingAlias(DelivzoneTableMap::DELIVERY, $delivery, $comparison); } /** @@ -380,18 +363,18 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * 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 + * @return ChildDelivzoneQuery 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); + $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -402,7 +385,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -423,18 +406,18 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * 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 + * @return ChildDelivzoneQuery 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); + $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -445,32 +428,31 @@ abstract class BaseDelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Area object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Area|ObjectCollection $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. + * @return ChildDelivzoneQuery The current query, for fluid interface */ public function filterByArea($area, $comparison = null) { - if ($area instanceof Area) { + if ($area instanceof \Thelia\Model\Area) { return $this - ->addUsingAlias(DelivzonePeer::AREA_ID, $area->getId(), $comparison); - } elseif ($area instanceof PropelObjectCollection) { + ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->getId(), $comparison); + } elseif ($area instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(DelivzonePeer::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByArea() only accepts arguments of type Area or PropelCollection'); + throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection'); } } @@ -480,7 +462,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * @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 + * @return ChildDelivzoneQuery The current query, for fluid interface */ public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -509,7 +491,7 @@ abstract class BaseDelivzoneQuery extends ModelCriteria /** * Use the Area relation Area object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -527,19 +509,94 @@ abstract class BaseDelivzoneQuery extends ModelCriteria /** * Exclude object from result * - * @param Delivzone $delivzone Object to remove from the list of results + * @param ChildDelivzone $delivzone Object to remove from the list of results * - * @return DelivzoneQuery The current query, for fluid interface + * @return ChildDelivzoneQuery The current query, for fluid interface */ public function prune($delivzone = null) { if ($delivzone) { - $this->addUsingAlias(DelivzonePeer::ID, $delivzone->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(DelivzoneTableMap::ID, $delivzone->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the delivzone table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + DelivzoneTableMap::clearInstancePool(); + DelivzoneTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildDelivzone or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildDelivzone object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(DelivzoneTableMap::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(); + + + DelivzoneTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + DelivzoneTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -547,31 +604,11 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return DelivzoneQuery The current query, for fluid interface + * @return ChildDelivzoneQuery 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); + return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -579,30 +616,51 @@ abstract class BaseDelivzoneQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return DelivzoneQuery The current query, for fluid interface + * @return ChildDelivzoneQuery 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); + return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildDelivzoneQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildDelivzoneQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return DelivzoneQuery The current query, for fluid interface + * @return ChildDelivzoneQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(DelivzonePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(DelivzoneTableMap::CREATED_AT); } /** * Order by create date asc * - * @return DelivzoneQuery The current query, for fluid interface + * @return ChildDelivzoneQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(DelivzonePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(DelivzoneTableMap::CREATED_AT); } -} + +} // DelivzoneQuery diff --git a/core/lib/Thelia/Model/om/BaseDocument.php b/core/lib/Thelia/Model/Base/Document.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseDocument.php rename to core/lib/Thelia/Model/Base/Document.php index c13846285..b12293f33 --- a/core/lib/Thelia/Model/om/BaseDocument.php +++ b/core/lib/Thelia/Model/Base/Document.php @@ -1,61 +1,69 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Document instance. If + * obj is an instance of Document, delegates to + * equals(Document). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Document The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Document The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [product_id] column value. * - * @return int + * @return int */ public function getProductId() { + return $this->product_id; } /** * Get the [category_id] column value. * - * @return int + * @return int */ public function getCategoryId() { + return $this->category_id; } /** * Get the [folder_id] column value. * - * @return int + * @return int */ public function getFolderId() { + return $this->folder_id; } /** * Get the [content_id] column value. * - * @return int + * @return int */ public function getContentId() { + return $this->content_id; } /** * Get the [file] column value. * - * @return string + * @return string */ public function getFile() { + return $this->file; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -251,97 +508,57 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Document The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = DocumentPeer::ID; + $this->modifiedColumns[] = DocumentTableMap::ID; } @@ -351,18 +568,18 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [product_id] column. * - * @param int $v new value - * @return Document The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Document The current object (for fluent API support) */ public function setProductId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->product_id !== $v) { $this->product_id = $v; - $this->modifiedColumns[] = DocumentPeer::PRODUCT_ID; + $this->modifiedColumns[] = DocumentTableMap::PRODUCT_ID; } if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { @@ -376,18 +593,18 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [category_id] column. * - * @param int $v new value - * @return Document The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Document The current object (for fluent API support) */ public function setCategoryId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->category_id !== $v) { $this->category_id = $v; - $this->modifiedColumns[] = DocumentPeer::CATEGORY_ID; + $this->modifiedColumns[] = DocumentTableMap::CATEGORY_ID; } if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { @@ -401,18 +618,18 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [folder_id] column. * - * @param int $v new value - * @return Document The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Document The current object (for fluent API support) */ public function setFolderId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->folder_id !== $v) { $this->folder_id = $v; - $this->modifiedColumns[] = DocumentPeer::FOLDER_ID; + $this->modifiedColumns[] = DocumentTableMap::FOLDER_ID; } if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { @@ -426,18 +643,18 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [content_id] column. * - * @param int $v new value - * @return Document The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Document The current object (for fluent API support) */ public function setContentId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->content_id !== $v) { $this->content_id = $v; - $this->modifiedColumns[] = DocumentPeer::CONTENT_ID; + $this->modifiedColumns[] = DocumentTableMap::CONTENT_ID; } if ($this->aContent !== null && $this->aContent->getId() !== $v) { @@ -451,18 +668,18 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [file] column. * - * @param string $v new value - * @return Document The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Document The current object (for fluent API support) */ public function setFile($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->file !== $v) { $this->file = $v; - $this->modifiedColumns[] = DocumentPeer::FILE; + $this->modifiedColumns[] = DocumentTableMap::FILE; } @@ -472,18 +689,18 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return Document The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Document The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = DocumentPeer::POSITION; + $this->modifiedColumns[] = DocumentTableMap::POSITION; } @@ -493,19 +710,17 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Document The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = DocumentTableMap::CREATED_AT; } } // if either are not null @@ -516,19 +731,17 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Document The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = DocumentTableMap::UPDATED_AT; } } // if either are not null @@ -546,7 +759,7 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -558,25 +771,53 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DocumentTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DocumentTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DocumentTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DocumentTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->folder_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DocumentTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : DocumentTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : DocumentTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : DocumentTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : DocumentTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -584,11 +825,11 @@ abstract class BaseDocument extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 9; // 9 = DocumentPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 9; // 9 = DocumentTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Document object", $e); + throw new PropelException("Error populating \Thelia\Model\Document object", 0, $e); } } @@ -607,7 +848,6 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { $this->aProduct = null; } @@ -627,12 +867,12 @@ abstract class BaseDocument extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -643,19 +883,19 @@ abstract class BaseDocument extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(DocumentTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildDocumentQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -671,26 +911,25 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Document::setDeleted() + * @see Document::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = DocumentQuery::create() + $deleteQuery = ChildDocumentQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -715,20 +954,19 @@ abstract class BaseDocument extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -738,16 +976,16 @@ abstract class BaseDocument extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(DocumentPeer::CREATED_AT)) { + if (!$this->isColumnModified(DocumentTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(DocumentPeer::UPDATED_AT)) { + if (!$this->isColumnModified(DocumentTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(DocumentPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(DocumentTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -759,7 +997,7 @@ abstract class BaseDocument extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - DocumentPeer::addInstanceToPool($this); + DocumentTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -778,19 +1016,19 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -835,15 +1073,15 @@ abstract class BaseDocument extends BaseObject implements Persistent if ($this->documentI18nsScheduledForDeletion !== null) { if (!$this->documentI18nsScheduledForDeletion->isEmpty()) { - DocumentI18nQuery::create() + \Thelia\Model\DocumentI18nQuery::create() ->filterByPrimaryKeys($this->documentI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->documentI18nsScheduledForDeletion = null; } } - if ($this->collDocumentI18ns !== null) { - foreach ($this->collDocumentI18ns as $referrerFK) { + if ($this->collDocumentI18ns !== null) { + foreach ($this->collDocumentI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -860,52 +1098,52 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = DocumentPeer::ID; + $this->modifiedColumns[] = DocumentTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . DocumentPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . DocumentTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(DocumentPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(DocumentTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(DocumentPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; + if ($this->isColumnModified(DocumentTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; } - if ($this->isColumnModified(DocumentPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; + if ($this->isColumnModified(DocumentTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; } - if ($this->isColumnModified(DocumentPeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`folder_id`'; + if ($this->isColumnModified(DocumentTableMap::FOLDER_ID)) { + $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; } - if ($this->isColumnModified(DocumentPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`content_id`'; + if ($this->isColumnModified(DocumentTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; } - if ($this->isColumnModified(DocumentPeer::FILE)) { - $modifiedColumns[':p' . $index++] = '`file`'; + if ($this->isColumnModified(DocumentTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; } - if ($this->isColumnModified(DocumentPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(DocumentTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(DocumentPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(DocumentTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(DocumentPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(DocumentTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `document` (%s) VALUES (%s)', + 'INSERT INTO document (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -914,45 +1152,45 @@ abstract class BaseDocument extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`product_id`': + case 'PRODUCT_ID': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`category_id`': + case 'CATEGORY_ID': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`folder_id`': + case 'FOLDER_ID': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; - case '`content_id`': + case 'CONTENT_ID': $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); break; - case '`file`': + case 'FILE': $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -962,142 +1200,32 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = DocumentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = DocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1107,7 +1235,7 @@ abstract class BaseDocument extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1152,22 +1280,22 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = DocumentTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getProductId(), @@ -1179,6 +1307,12 @@ abstract class BaseDocument extends BaseObject implements Persistent $keys[7] => $this->getCreatedAt(), $keys[8] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aProduct) { $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -1203,27 +1337,27 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = DocumentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = DocumentTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1268,17 +1402,17 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = DocumentPeer::getFieldNames($keyType); + $keys = DocumentTableMap::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]]); @@ -1298,17 +1432,17 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(DocumentPeer::DATABASE_NAME); + $criteria = new Criteria(DocumentTableMap::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); + if ($this->isColumnModified(DocumentTableMap::ID)) $criteria->add(DocumentTableMap::ID, $this->id); + if ($this->isColumnModified(DocumentTableMap::PRODUCT_ID)) $criteria->add(DocumentTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(DocumentTableMap::CATEGORY_ID)) $criteria->add(DocumentTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(DocumentTableMap::FOLDER_ID)) $criteria->add(DocumentTableMap::FOLDER_ID, $this->folder_id); + if ($this->isColumnModified(DocumentTableMap::CONTENT_ID)) $criteria->add(DocumentTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(DocumentTableMap::FILE)) $criteria->add(DocumentTableMap::FILE, $this->file); + if ($this->isColumnModified(DocumentTableMap::POSITION)) $criteria->add(DocumentTableMap::POSITION, $this->position); + if ($this->isColumnModified(DocumentTableMap::CREATED_AT)) $criteria->add(DocumentTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(DocumentTableMap::UPDATED_AT)) $criteria->add(DocumentTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1323,15 +1457,15 @@ abstract class BaseDocument extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(DocumentPeer::DATABASE_NAME); - $criteria->add(DocumentPeer::ID, $this->id); + $criteria = new Criteria(DocumentTableMap::DATABASE_NAME); + $criteria->add(DocumentTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1341,7 +1475,7 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1365,9 +1499,9 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1381,12 +1515,10 @@ abstract class BaseDocument extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1394,8 +1526,6 @@ abstract class BaseDocument extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1412,8 +1542,8 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Document Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1427,31 +1557,13 @@ abstract class BaseDocument extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildProduct object. * - * 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) + * @param ChildProduct $v + * @return \Thelia\Model\Document The current object (for fluent API support) * @throws PropelException */ - public function setProduct(Product $v = null) + public function setProduct(ChildProduct $v = null) { if ($v === null) { $this->setProductId(NULL); @@ -1462,7 +1574,7 @@ abstract class BaseDocument extends BaseObject implements Persistent $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 this object has already been added to the ChildProduct object, it will not be re-added. if ($v !== null) { $v->addDocument($this); } @@ -1473,17 +1585,16 @@ abstract class BaseDocument extends BaseObject implements Persistent /** - * Get the associated Product object + * Get the associated ChildProduct object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null, $doQuery = true) + public function getProduct(ConnectionInterface $con = null) { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::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 @@ -1497,13 +1608,13 @@ abstract class BaseDocument extends BaseObject implements Persistent } /** - * Declares an association between this object and a Category object. + * Declares an association between this object and a ChildCategory object. * - * @param Category $v - * @return Document The current object (for fluent API support) + * @param ChildCategory $v + * @return \Thelia\Model\Document The current object (for fluent API support) * @throws PropelException */ - public function setCategory(Category $v = null) + public function setCategory(ChildCategory $v = null) { if ($v === null) { $this->setCategoryId(NULL); @@ -1514,7 +1625,7 @@ abstract class BaseDocument extends BaseObject implements Persistent $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 this object has already been added to the ChildCategory object, it will not be re-added. if ($v !== null) { $v->addDocument($this); } @@ -1525,17 +1636,16 @@ abstract class BaseDocument extends BaseObject implements Persistent /** - * Get the associated Category object + * Get the associated ChildCategory object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null, $doQuery = true) + public function getCategory(ConnectionInterface $con = null) { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::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 @@ -1549,13 +1659,13 @@ abstract class BaseDocument extends BaseObject implements Persistent } /** - * Declares an association between this object and a Content object. + * Declares an association between this object and a ChildContent object. * - * @param Content $v - * @return Document The current object (for fluent API support) + * @param ChildContent $v + * @return \Thelia\Model\Document The current object (for fluent API support) * @throws PropelException */ - public function setContent(Content $v = null) + public function setContent(ChildContent $v = null) { if ($v === null) { $this->setContentId(NULL); @@ -1566,7 +1676,7 @@ abstract class BaseDocument extends BaseObject implements Persistent $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 this object has already been added to the ChildContent object, it will not be re-added. if ($v !== null) { $v->addDocument($this); } @@ -1577,17 +1687,16 @@ abstract class BaseDocument extends BaseObject implements Persistent /** - * Get the associated Content object + * Get the associated ChildContent object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. * @throws PropelException */ - public function getContent(PropelPDO $con = null, $doQuery = true) + public function getContent(ConnectionInterface $con = null) { - if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::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 @@ -1601,13 +1710,13 @@ abstract class BaseDocument extends BaseObject implements Persistent } /** - * Declares an association between this object and a Folder object. + * Declares an association between this object and a ChildFolder object. * - * @param Folder $v - * @return Document The current object (for fluent API support) + * @param ChildFolder $v + * @return \Thelia\Model\Document The current object (for fluent API support) * @throws PropelException */ - public function setFolder(Folder $v = null) + public function setFolder(ChildFolder $v = null) { if ($v === null) { $this->setFolderId(NULL); @@ -1618,7 +1727,7 @@ abstract class BaseDocument extends BaseObject implements Persistent $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 this object has already been added to the ChildFolder object, it will not be re-added. if ($v !== null) { $v->addDocument($this); } @@ -1629,17 +1738,16 @@ abstract class BaseDocument extends BaseObject implements Persistent /** - * Get the associated Folder object + * Get the associated ChildFolder object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Folder The associated Folder object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFolder The associated ChildFolder object. * @throws PropelException */ - public function getFolder(PropelPDO $con = null, $doQuery = true) + public function getFolder(ConnectionInterface $con = null) { - if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { - $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); + if ($this->aFolder === null && ($this->folder_id !== null)) { + $this->aFolder = ChildFolderQuery::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 @@ -1658,13 +1766,13 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('DocumentI18n' == $relationName) { - $this->initDocumentI18ns(); + return $this->initDocumentI18ns(); } } @@ -1674,21 +1782,16 @@ abstract class BaseDocument extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collDocumentI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collDocumentI18ns collection loaded partially - * - * @return void + * Reset is the collDocumentI18ns collection loaded partially. */ public function resetPartialDocumentI18ns($v = true) { @@ -1702,7 +1805,7 @@ abstract class BaseDocument extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1712,25 +1815,25 @@ abstract class BaseDocument extends BaseObject implements Persistent if (null !== $this->collDocumentI18ns && !$overrideExisting) { return; } - $this->collDocumentI18ns = new PropelObjectCollection(); - $this->collDocumentI18ns->setModel('DocumentI18n'); + $this->collDocumentI18ns = new ObjectCollection(); + $this->collDocumentI18ns->setModel('\Thelia\Model\DocumentI18n'); } /** - * Gets an array of DocumentI18n objects which contain a foreign key that references this object. + * Gets an array of ChildDocumentI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildDocument is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildDocumentI18n[] List of ChildDocumentI18n objects * @throws PropelException */ - public function getDocumentI18ns($criteria = null, PropelPDO $con = null) + public function getDocumentI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collDocumentI18nsPartial && !$this->isNew(); if (null === $this->collDocumentI18ns || null !== $criteria || $partial) { @@ -1738,29 +1841,31 @@ abstract class BaseDocument extends BaseObject implements Persistent // return empty collection $this->initDocumentI18ns(); } else { - $collDocumentI18ns = DocumentI18nQuery::create(null, $criteria) + $collDocumentI18ns = ChildDocumentI18nQuery::create(null, $criteria) ->filterByDocument($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collDocumentI18nsPartial && count($collDocumentI18ns)) { - $this->initDocumentI18ns(false); + $this->initDocumentI18ns(false); - foreach($collDocumentI18ns as $obj) { - if (false == $this->collDocumentI18ns->contains($obj)) { - $this->collDocumentI18ns->append($obj); + foreach ($collDocumentI18ns as $obj) { + if (false == $this->collDocumentI18ns->contains($obj)) { + $this->collDocumentI18ns->append($obj); + } } - } - $this->collDocumentI18nsPartial = true; + $this->collDocumentI18nsPartial = true; } $collDocumentI18ns->getInternalIterator()->rewind(); + return $collDocumentI18ns; } - if($partial && $this->collDocumentI18ns) { - foreach($this->collDocumentI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collDocumentI18ns) { + foreach ($this->collDocumentI18ns as $obj) { + if ($obj->isNew()) { $collDocumentI18ns[] = $obj; } } @@ -1780,15 +1885,19 @@ abstract class BaseDocument extends BaseObject implements Persistent * It will 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) + * @param Collection $documentI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildDocument The current object (for fluent API support) */ - public function setDocumentI18ns(PropelCollection $documentI18ns, PropelPDO $con = null) + public function setDocumentI18ns(Collection $documentI18ns, ConnectionInterface $con = null) { $documentI18nsToDelete = $this->getDocumentI18ns(new Criteria(), $con)->diff($documentI18ns); - $this->documentI18nsScheduledForDeletion = unserialize(serialize($documentI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->documentI18nsScheduledForDeletion = clone $documentI18nsToDelete; foreach ($documentI18nsToDelete as $documentI18nRemoved) { $documentI18nRemoved->setDocument(null); @@ -1808,13 +1917,13 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Returns the number of related DocumentI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related DocumentI18n objects. * @throws PropelException */ - public function countDocumentI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countDocumentI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collDocumentI18nsPartial && !$this->isNew(); if (null === $this->collDocumentI18ns || null !== $criteria || $partial) { @@ -1822,10 +1931,11 @@ abstract class BaseDocument extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getDocumentI18ns()); } - $query = DocumentI18nQuery::create(null, $criteria); + + $query = ChildDocumentI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1839,13 +1949,13 @@ abstract class BaseDocument extends BaseObject implements Persistent } /** - * Method called to associate a DocumentI18n object to this object - * through the DocumentI18n foreign key attribute. + * Method called to associate a ChildDocumentI18n object to this object + * through the ChildDocumentI18n foreign key attribute. * - * @param DocumentI18n $l DocumentI18n - * @return Document The current object (for fluent API support) + * @param ChildDocumentI18n $l ChildDocumentI18n + * @return \Thelia\Model\Document The current object (for fluent API support) */ - public function addDocumentI18n(DocumentI18n $l) + public function addDocumentI18n(ChildDocumentI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1855,6 +1965,7 @@ abstract class BaseDocument extends BaseObject implements Persistent $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); } @@ -1863,7 +1974,7 @@ abstract class BaseDocument extends BaseObject implements Persistent } /** - * @param DocumentI18n $documentI18n The documentI18n object to add. + * @param DocumentI18n $documentI18n The documentI18n object to add. */ protected function doAddDocumentI18n($documentI18n) { @@ -1872,8 +1983,8 @@ abstract class BaseDocument extends BaseObject implements Persistent } /** - * @param DocumentI18n $documentI18n The documentI18n object to remove. - * @return Document The current object (for fluent API support) + * @param DocumentI18n $documentI18n The documentI18n object to remove. + * @return ChildDocument The current object (for fluent API support) */ public function removeDocumentI18n($documentI18n) { @@ -1905,8 +2016,6 @@ abstract class BaseDocument extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1918,40 +2027,25 @@ abstract class BaseDocument extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { 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->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collDocumentI18ns instanceof PropelCollection) { + if ($this->collDocumentI18ns instanceof Collection) { $this->collDocumentI18ns->clearIterator(); } $this->collDocumentI18ns = null; @@ -1962,23 +2056,13 @@ abstract class BaseDocument extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(DocumentTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1986,11 +2070,11 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * 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) + * @return ChildDocument The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = DocumentPeer::UPDATED_AT; + $this->modifiedColumns[] = DocumentTableMap::UPDATED_AT; return $this; } @@ -2002,9 +2086,9 @@ abstract class BaseDocument extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Document The current object (for fluent API support) + * @return ChildDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2025,10 +2109,10 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return DocumentI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildDocumentI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collDocumentI18ns) { @@ -2041,10 +2125,10 @@ abstract class BaseDocument extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new DocumentI18n(); + $translation = new ChildDocumentI18n(); $translation->setLocale($locale); } else { - $translation = DocumentI18nQuery::create() + $translation = ChildDocumentI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -2059,14 +2143,14 @@ abstract class BaseDocument extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Document The current object (for fluent API support) + * @return ChildDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - DocumentI18nQuery::create() + ChildDocumentI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -2086,10 +2170,10 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return DocumentI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildDocumentI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -2098,7 +2182,7 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -2109,8 +2193,8 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2122,7 +2206,7 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -2133,8 +2217,8 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2146,7 +2230,7 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -2157,8 +2241,8 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2170,7 +2254,7 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -2181,8 +2265,8 @@ abstract class BaseDocument extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -2190,4 +2274,122 @@ abstract class BaseDocument extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/DocumentI18n.php b/core/lib/Thelia/Model/Base/DocumentI18n.php new file mode 100644 index 000000000..adc6acd36 --- /dev/null +++ b/core/lib/Thelia/Model/Base/DocumentI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\DocumentI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another DocumentI18n instance. If + * obj is an instance of DocumentI18n, delegates to + * equals(DocumentI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return DocumentI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return DocumentI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\DocumentI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = DocumentI18nTableMap::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 \Thelia\Model\DocumentI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = DocumentI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = DocumentI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = DocumentI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = DocumentI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = DocumentI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DocumentI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DocumentI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DocumentI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DocumentI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DocumentI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : DocumentI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = DocumentI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\DocumentI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(DocumentI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildDocumentI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aDocument = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see DocumentI18n::setDeleted() + * @see DocumentI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildDocumentI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + } + + $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); + DocumentI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(DocumentI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(DocumentI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(DocumentI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(DocumentI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(DocumentI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(DocumentI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = DocumentI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['DocumentI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['DocumentI18n'][serialize($this->getPrimaryKey())] = true; + $keys = DocumentI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = DocumentI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = DocumentI18nTableMap::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(DocumentI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(DocumentI18nTableMap::ID)) $criteria->add(DocumentI18nTableMap::ID, $this->id); + if ($this->isColumnModified(DocumentI18nTableMap::LOCALE)) $criteria->add(DocumentI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(DocumentI18nTableMap::TITLE)) $criteria->add(DocumentI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(DocumentI18nTableMap::DESCRIPTION)) $criteria->add(DocumentI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(DocumentI18nTableMap::CHAPO)) $criteria->add(DocumentI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(DocumentI18nTableMap::POSTSCRIPTUM)) $criteria->add(DocumentI18nTableMap::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(DocumentI18nTableMap::DATABASE_NAME); + $criteria->add(DocumentI18nTableMap::ID, $this->id); + $criteria->add(DocumentI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildDocument object. + * + * @param ChildDocument $v + * @return \Thelia\Model\DocumentI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setDocument(ChildDocument $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 ChildDocument object, it will not be re-added. + if ($v !== null) { + $v->addDocumentI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildDocument object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildDocument The associated ChildDocument object. + * @throws PropelException + */ + public function getDocument(ConnectionInterface $con = null) + { + if ($this->aDocument === null && ($this->id !== null)) { + $this->aDocument = ChildDocumentQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aDocument = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(DocumentI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php b/core/lib/Thelia/Model/Base/DocumentI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php rename to core/lib/Thelia/Model/Base/DocumentI18nQuery.php index 307471f35..47b598bf0 --- a/core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php +++ b/core/lib/Thelia/Model/Base/DocumentI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return DocumentI18n|DocumentI18n[]|mixed the result, formatted by the current formatter + * @return ChildDocumentI18n|array|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 + if ((null !== ($obj = DocumentI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(DocumentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(DocumentI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return DocumentI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildDocumentI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `document_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new DocumentI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildDocumentI18n(); $obj->hydrate($row); - DocumentI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + DocumentI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return DocumentI18n|DocumentI18n[]|mixed the result, formatted by the current formatter + * @return ChildDocumentI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|DocumentI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return DocumentI18nQuery The current query, for fluid interface + * @return ChildDocumentI18nQuery 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); + $this->addUsingAlias(DocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(DocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return DocumentI18nQuery The current query, for fluid interface + * @return ChildDocumentI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(DocumentI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(DocumentI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByDocument() @@ -270,18 +266,18 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * 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 + * @return ChildDocumentI18nQuery 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); + $this->addUsingAlias(DocumentI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(DocumentI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DocumentI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(DocumentI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * 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 + * @return ChildDocumentI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(DocumentI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * 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 + * @return ChildDocumentI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(DocumentI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * 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 + * @return ChildDocumentI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(DocumentI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * 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 + * @return ChildDocumentI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(DocumentI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * 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 + * @return ChildDocumentI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(DocumentI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Document object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Document|ObjectCollection $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. + * @return ChildDocumentI18nQuery The current query, for fluid interface */ public function filterByDocument($document, $comparison = null) { - if ($document instanceof Document) { + if ($document instanceof \Thelia\Model\Document) { return $this - ->addUsingAlias(DocumentI18nPeer::ID, $document->getId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { + ->addUsingAlias(DocumentI18nTableMap::ID, $document->getId(), $comparison); + } elseif ($document instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(DocumentI18nPeer::ID, $document->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(DocumentI18nTableMap::ID, $document->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); + throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria * @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 + * @return ChildDocumentI18nQuery The current query, for fluid interface */ public function joinDocument($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria /** * Use the Document relation Document object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseDocumentI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param DocumentI18n $documentI18n Object to remove from the list of results + * @param ChildDocumentI18n $documentI18n Object to remove from the list of results * - * @return DocumentI18nQuery The current query, for fluid interface + * @return ChildDocumentI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(DocumentI18nTableMap::ID), $documentI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(DocumentI18nTableMap::LOCALE), $documentI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + DocumentI18nTableMap::clearInstancePool(); + DocumentI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildDocumentI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildDocumentI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(DocumentI18nTableMap::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(); + + + DocumentI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + DocumentI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // DocumentI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseDocumentQuery.php b/core/lib/Thelia/Model/Base/DocumentQuery.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseDocumentQuery.php rename to core/lib/Thelia/Model/Base/DocumentQuery.php index 5e5f95712..20c897994 --- a/core/lib/Thelia/Model/om/BaseDocumentQuery.php +++ b/core/lib/Thelia/Model/Base/DocumentQuery.php @@ -1,127 +1,124 @@ setModelAlias($modelAlias); } @@ -142,21 +139,21 @@ abstract class BaseDocumentQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Document|Document[]|mixed the result, formatted by the current formatter + * @return ChildDocument|array|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 + if ((null !== ($obj = DocumentTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(DocumentTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -168,46 +165,31 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Document A model object, or null if the key is not found - * @throws PropelException + * @return ChildDocument A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Document(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildDocument(); $obj->hydrate($row); - DocumentPeer::addInstanceToPool($obj, (string) $key); + DocumentTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -218,19 +200,19 @@ abstract class BaseDocumentQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Document|Document[]|mixed the result, formatted by the current formatter + * @return ChildDocument|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -239,22 +221,22 @@ abstract class BaseDocumentQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Document[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -262,12 +244,12 @@ abstract class BaseDocumentQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return DocumentQuery The current query, for fluid interface + * @return ChildDocumentQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(DocumentPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(DocumentTableMap::ID, $key, Criteria::EQUAL); } /** @@ -275,12 +257,12 @@ abstract class BaseDocumentQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return DocumentQuery The current query, for fluid interface + * @return ChildDocumentQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(DocumentPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(DocumentTableMap::ID, $keys, Criteria::IN); } /** @@ -290,8 +272,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -300,18 +281,18 @@ abstract class BaseDocumentQuery extends ModelCriteria * 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 + * @return ChildDocumentQuery 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); + $this->addUsingAlias(DocumentTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(DocumentPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DocumentTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -322,7 +303,7 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentPeer::ID, $id, $comparison); + return $this->addUsingAlias(DocumentTableMap::ID, $id, $comparison); } /** @@ -332,8 +313,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $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 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 * * * @see filterByProduct() @@ -344,18 +324,18 @@ abstract class BaseDocumentQuery extends ModelCriteria * 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 + * @return ChildDocumentQuery 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); + $this->addUsingAlias(DocumentTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($productId['max'])) { - $this->addUsingAlias(DocumentPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DocumentTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -366,7 +346,7 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentPeer::PRODUCT_ID, $productId, $comparison); + return $this->addUsingAlias(DocumentTableMap::PRODUCT_ID, $productId, $comparison); } /** @@ -376,8 +356,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $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 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 * * * @see filterByCategory() @@ -388,18 +367,18 @@ abstract class BaseDocumentQuery extends ModelCriteria * 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 + * @return ChildDocumentQuery 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); + $this->addUsingAlias(DocumentTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($categoryId['max'])) { - $this->addUsingAlias(DocumentPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DocumentTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -410,7 +389,7 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentPeer::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(DocumentTableMap::CATEGORY_ID, $categoryId, $comparison); } /** @@ -420,8 +399,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $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 + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 * * * @see filterByFolder() @@ -432,18 +410,18 @@ abstract class BaseDocumentQuery extends ModelCriteria * 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 + * @return ChildDocumentQuery 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); + $this->addUsingAlias(DocumentTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($folderId['max'])) { - $this->addUsingAlias(DocumentPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DocumentTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -454,7 +432,7 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentPeer::FOLDER_ID, $folderId, $comparison); + return $this->addUsingAlias(DocumentTableMap::FOLDER_ID, $folderId, $comparison); } /** @@ -464,8 +442,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $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 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 * * * @see filterByContent() @@ -476,18 +453,18 @@ abstract class BaseDocumentQuery extends ModelCriteria * 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 + * @return ChildDocumentQuery 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); + $this->addUsingAlias(DocumentTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($contentId['max'])) { - $this->addUsingAlias(DocumentPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DocumentTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -498,7 +475,7 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentPeer::CONTENT_ID, $contentId, $comparison); + return $this->addUsingAlias(DocumentTableMap::CONTENT_ID, $contentId, $comparison); } /** @@ -514,7 +491,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * 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 + * @return ChildDocumentQuery The current query, for fluid interface */ public function filterByFile($file = null, $comparison = null) { @@ -527,7 +504,7 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentPeer::FILE, $file, $comparison); + return $this->addUsingAlias(DocumentTableMap::FILE, $file, $comparison); } /** @@ -537,8 +514,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -547,18 +523,18 @@ abstract class BaseDocumentQuery extends ModelCriteria * 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 + * @return ChildDocumentQuery 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); + $this->addUsingAlias(DocumentTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(DocumentPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DocumentTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -569,7 +545,7 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(DocumentTableMap::POSITION, $position, $comparison); } /** @@ -590,18 +566,18 @@ abstract class BaseDocumentQuery extends ModelCriteria * 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 + * @return ChildDocumentQuery 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); + $this->addUsingAlias(DocumentTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(DocumentPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DocumentTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -612,7 +588,7 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(DocumentTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -633,18 +609,18 @@ abstract class BaseDocumentQuery extends ModelCriteria * 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 + * @return ChildDocumentQuery 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); + $this->addUsingAlias(DocumentTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(DocumentPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(DocumentTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -655,32 +631,31 @@ abstract class BaseDocumentQuery extends ModelCriteria } } - return $this->addUsingAlias(DocumentPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(DocumentTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildDocumentQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(DocumentPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(DocumentTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(DocumentPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(DocumentTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -690,7 +665,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * @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 + * @return ChildDocumentQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -719,7 +694,7 @@ abstract class BaseDocumentQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -735,28 +710,27 @@ abstract class BaseDocumentQuery extends ModelCriteria } /** - * Filter the query by a related Category object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Category|ObjectCollection $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. + * @return ChildDocumentQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = null) { - if ($category instanceof Category) { + if ($category instanceof \Thelia\Model\Category) { return $this - ->addUsingAlias(DocumentPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { + ->addUsingAlias(DocumentTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(DocumentPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(DocumentTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); } } @@ -766,7 +740,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * @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 + * @return ChildDocumentQuery The current query, for fluid interface */ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -795,7 +769,7 @@ abstract class BaseDocumentQuery extends ModelCriteria /** * Use the Category relation Category object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -811,28 +785,27 @@ abstract class BaseDocumentQuery extends ModelCriteria } /** - * Filter the query by a related Content object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Content|ObjectCollection $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. + * @return ChildDocumentQuery The current query, for fluid interface */ public function filterByContent($content, $comparison = null) { - if ($content instanceof Content) { + if ($content instanceof \Thelia\Model\Content) { return $this - ->addUsingAlias(DocumentPeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { + ->addUsingAlias(DocumentTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(DocumentPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(DocumentTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); } } @@ -842,7 +815,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * @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 + * @return ChildDocumentQuery The current query, for fluid interface */ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -871,7 +844,7 @@ abstract class BaseDocumentQuery extends ModelCriteria /** * Use the Content relation Content object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -887,28 +860,27 @@ abstract class BaseDocumentQuery extends ModelCriteria } /** - * Filter the query by a related Folder object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Folder|ObjectCollection $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. + * @return ChildDocumentQuery The current query, for fluid interface */ public function filterByFolder($folder, $comparison = null) { - if ($folder instanceof Folder) { + if ($folder instanceof \Thelia\Model\Folder) { return $this - ->addUsingAlias(DocumentPeer::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { + ->addUsingAlias(DocumentTableMap::FOLDER_ID, $folder->getId(), $comparison); + } elseif ($folder instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(DocumentPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(DocumentTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); + throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); } } @@ -918,7 +890,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * @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 + * @return ChildDocumentQuery The current query, for fluid interface */ public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -947,7 +919,7 @@ abstract class BaseDocumentQuery extends ModelCriteria /** * Use the Folder relation Folder object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -963,26 +935,25 @@ abstract class BaseDocumentQuery extends ModelCriteria } /** - * Filter the query by a related DocumentI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\DocumentI18n|ObjectCollection $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. + * @return ChildDocumentQuery The current query, for fluid interface */ public function filterByDocumentI18n($documentI18n, $comparison = null) { - if ($documentI18n instanceof DocumentI18n) { + if ($documentI18n instanceof \Thelia\Model\DocumentI18n) { return $this - ->addUsingAlias(DocumentPeer::ID, $documentI18n->getId(), $comparison); - } elseif ($documentI18n instanceof PropelObjectCollection) { + ->addUsingAlias(DocumentTableMap::ID, $documentI18n->getId(), $comparison); + } elseif ($documentI18n instanceof ObjectCollection) { return $this ->useDocumentI18nQuery() ->filterByPrimaryKeys($documentI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDocumentI18n() only accepts arguments of type DocumentI18n or PropelCollection'); + throw new PropelException('filterByDocumentI18n() only accepts arguments of type \Thelia\Model\DocumentI18n or Collection'); } } @@ -992,7 +963,7 @@ abstract class BaseDocumentQuery extends ModelCriteria * @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 + * @return ChildDocumentQuery The current query, for fluid interface */ public function joinDocumentI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -1021,7 +992,7 @@ abstract class BaseDocumentQuery extends ModelCriteria /** * Use the DocumentI18n relation DocumentI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1039,19 +1010,94 @@ abstract class BaseDocumentQuery extends ModelCriteria /** * Exclude object from result * - * @param Document $document Object to remove from the list of results + * @param ChildDocument $document Object to remove from the list of results * - * @return DocumentQuery The current query, for fluid interface + * @return ChildDocumentQuery The current query, for fluid interface */ public function prune($document = null) { if ($document) { - $this->addUsingAlias(DocumentPeer::ID, $document->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(DocumentTableMap::ID, $document->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the document table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + DocumentTableMap::clearInstancePool(); + DocumentTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildDocument or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildDocument object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(DocumentTableMap::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(); + + + DocumentTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + DocumentTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -1059,31 +1105,11 @@ abstract class BaseDocumentQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return DocumentQuery The current query, for fluid interface + * @return ChildDocumentQuery 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); + return $this->addUsingAlias(DocumentTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -1091,32 +1117,53 @@ abstract class BaseDocumentQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return DocumentQuery The current query, for fluid interface + * @return ChildDocumentQuery 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); + return $this->addUsingAlias(DocumentTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildDocumentQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(DocumentTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildDocumentQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(DocumentTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return DocumentQuery The current query, for fluid interface + * @return ChildDocumentQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(DocumentPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(DocumentTableMap::CREATED_AT); } /** * Order by create date asc * - * @return DocumentQuery The current query, for fluid interface + * @return ChildDocumentQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(DocumentPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(DocumentTableMap::CREATED_AT); } + // i18n behavior /** @@ -1126,9 +1173,9 @@ abstract class BaseDocumentQuery extends ModelCriteria * @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 + * @return ChildDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'DocumentI18n'; @@ -1144,9 +1191,9 @@ abstract class BaseDocumentQuery extends ModelCriteria * @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 + * @return ChildDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1165,13 +1212,13 @@ abstract class BaseDocumentQuery extends ModelCriteria * @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 + * @return ChildDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'DocumentI18n', 'Thelia\Model\DocumentI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'DocumentI18n', '\Thelia\Model\DocumentI18nQuery'); } -} +} // DocumentQuery diff --git a/core/lib/Thelia/Model/om/BaseFeature.php b/core/lib/Thelia/Model/Base/Feature.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseFeature.php rename to core/lib/Thelia/Model/Base/Feature.php index 6aeaa9410..33125c87b --- a/core/lib/Thelia/Model/om/BaseFeature.php +++ b/core/lib/Thelia/Model/Base/Feature.php @@ -1,61 +1,69 @@ applyDefaultValues(); } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Feature instance. If + * obj is an instance of Feature, delegates to + * equals(Feature). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Feature The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Feature The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [visible] column value. * - * @return int + * @return int */ public function getVisible() { + return $this->visible; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -236,97 +481,57 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Feature The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = FeaturePeer::ID; + $this->modifiedColumns[] = FeatureTableMap::ID; } @@ -336,18 +541,18 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Set the value of [visible] column. * - * @param int $v new value - * @return Feature The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Feature The current object (for fluent API support) */ public function setVisible($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->visible !== $v) { $this->visible = $v; - $this->modifiedColumns[] = FeaturePeer::VISIBLE; + $this->modifiedColumns[] = FeatureTableMap::VISIBLE; } @@ -357,18 +562,18 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return Feature The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Feature The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = FeaturePeer::POSITION; + $this->modifiedColumns[] = FeatureTableMap::POSITION; } @@ -378,19 +583,17 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Feature The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = FeatureTableMap::CREATED_AT; } } // if either are not null @@ -401,19 +604,17 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Feature The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = FeatureTableMap::UPDATED_AT; } } // if either are not null @@ -435,7 +636,7 @@ abstract class BaseFeature extends BaseObject implements Persistent return false; } - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -447,21 +648,41 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -469,11 +690,11 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = FeaturePeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 5; // 5 = FeatureTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Feature object", $e); + throw new PropelException("Error populating \Thelia\Model\Feature object", 0, $e); } } @@ -492,7 +713,6 @@ abstract class BaseFeature extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -500,12 +720,12 @@ abstract class BaseFeature extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -516,19 +736,19 @@ abstract class BaseFeature extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FeatureTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildFeatureQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -536,37 +756,36 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->collFeatureProds = null; - $this->collFeatureCategorys = null; + $this->collFeatureCategories = null; $this->collFeatureI18ns = null; - $this->collCategorys = null; + $this->collCategories = null; } // if (deep) } /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Feature::setDeleted() + * @see Feature::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = FeatureQuery::create() + $deleteQuery = ChildFeatureQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -591,20 +810,19 @@ abstract class BaseFeature extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -614,16 +832,16 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(FeaturePeer::CREATED_AT)) { + if (!$this->isColumnModified(FeatureTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(FeaturePeer::UPDATED_AT)) { + if (!$this->isColumnModified(FeatureTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FeaturePeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(FeatureTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -635,7 +853,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - FeaturePeer::addInstanceToPool($this); + FeatureTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -654,12 +872,12 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -676,26 +894,27 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->resetModified(); } - if ($this->categorysScheduledForDeletion !== null) { - if (!$this->categorysScheduledForDeletion->isEmpty()) { + if ($this->categoriesScheduledForDeletion !== null) { + if (!$this->categoriesScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->categorysScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + $pk = $this->getPrimaryKey(); + foreach ($this->categoriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($remotePk, $pk); } + FeatureCategoryQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); - $this->categorysScheduledForDeletion = null; + $this->categoriesScheduledForDeletion = null; } - foreach ($this->getCategorys() as $category) { + foreach ($this->getCategories() as $category) { if ($category->isModified()) { $category->save($con); } } - } elseif ($this->collCategorys) { - foreach ($this->collCategorys as $category) { + } elseif ($this->collCategories) { + foreach ($this->collCategories as $category) { if ($category->isModified()) { $category->save($con); } @@ -704,15 +923,15 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($this->featureAvsScheduledForDeletion !== null) { if (!$this->featureAvsScheduledForDeletion->isEmpty()) { - FeatureAvQuery::create() + \Thelia\Model\FeatureAvQuery::create() ->filterByPrimaryKeys($this->featureAvsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->featureAvsScheduledForDeletion = null; } } - if ($this->collFeatureAvs !== null) { - foreach ($this->collFeatureAvs as $referrerFK) { + if ($this->collFeatureAvs !== null) { + foreach ($this->collFeatureAvs as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -721,32 +940,32 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($this->featureProdsScheduledForDeletion !== null) { if (!$this->featureProdsScheduledForDeletion->isEmpty()) { - FeatureProdQuery::create() + \Thelia\Model\FeatureProdQuery::create() ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->featureProdsScheduledForDeletion = null; } } - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { + 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)) + if ($this->featureCategoriesScheduledForDeletion !== null) { + if (!$this->featureCategoriesScheduledForDeletion->isEmpty()) { + \Thelia\Model\FeatureCategoryQuery::create() + ->filterByPrimaryKeys($this->featureCategoriesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->featureCategorysScheduledForDeletion = null; + $this->featureCategoriesScheduledForDeletion = null; } } - if ($this->collFeatureCategorys !== null) { - foreach ($this->collFeatureCategorys as $referrerFK) { + if ($this->collFeatureCategories !== null) { + foreach ($this->collFeatureCategories as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -755,15 +974,15 @@ abstract class BaseFeature extends BaseObject implements Persistent if ($this->featureI18nsScheduledForDeletion !== null) { if (!$this->featureI18nsScheduledForDeletion->isEmpty()) { - FeatureI18nQuery::create() + \Thelia\Model\FeatureI18nQuery::create() ->filterByPrimaryKeys($this->featureI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->featureI18nsScheduledForDeletion = null; } } - if ($this->collFeatureI18ns !== null) { - foreach ($this->collFeatureI18ns as $referrerFK) { + if ($this->collFeatureI18ns !== null) { + foreach ($this->collFeatureI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -780,40 +999,40 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = FeaturePeer::ID; + $this->modifiedColumns[] = FeatureTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeaturePeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeaturePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(FeatureTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(FeaturePeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; + if ($this->isColumnModified(FeatureTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; } - if ($this->isColumnModified(FeaturePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(FeatureTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(FeaturePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(FeatureTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(FeatureTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `feature` (%s) VALUES (%s)', + 'INSERT INTO feature (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -822,33 +1041,33 @@ abstract class BaseFeature extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`visible`': + case 'VISIBLE': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -858,136 +1077,32 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = FeatureTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -997,7 +1112,7 @@ abstract class BaseFeature extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1030,22 +1145,22 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = FeatureTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getVisible(), @@ -1053,6 +1168,12 @@ abstract class BaseFeature extends BaseObject implements Persistent $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collFeatureAvs) { $result['FeatureAvs'] = $this->collFeatureAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1060,8 +1181,8 @@ abstract class BaseFeature extends BaseObject implements Persistent 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->collFeatureCategories) { + $result['FeatureCategories'] = $this->collFeatureCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collFeatureI18ns) { $result['FeatureI18ns'] = $this->collFeatureI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1074,27 +1195,27 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = FeatureTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1127,17 +1248,17 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = FeaturePeer::getFieldNames($keyType); + $keys = FeatureTableMap::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]]); @@ -1153,13 +1274,13 @@ abstract class BaseFeature extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(FeaturePeer::DATABASE_NAME); + $criteria = new Criteria(FeatureTableMap::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); + if ($this->isColumnModified(FeatureTableMap::ID)) $criteria->add(FeatureTableMap::ID, $this->id); + if ($this->isColumnModified(FeatureTableMap::VISIBLE)) $criteria->add(FeatureTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(FeatureTableMap::POSITION)) $criteria->add(FeatureTableMap::POSITION, $this->position); + if ($this->isColumnModified(FeatureTableMap::CREATED_AT)) $criteria->add(FeatureTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FeatureTableMap::UPDATED_AT)) $criteria->add(FeatureTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1174,15 +1295,15 @@ abstract class BaseFeature extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(FeaturePeer::DATABASE_NAME); - $criteria->add(FeaturePeer::ID, $this->id); + $criteria = new Criteria(FeatureTableMap::DATABASE_NAME); + $criteria->add(FeatureTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1192,7 +1313,7 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1216,9 +1337,9 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1228,12 +1349,10 @@ abstract class BaseFeature extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1247,7 +1366,7 @@ abstract class BaseFeature extends BaseObject implements Persistent } } - foreach ($this->getFeatureCategorys() as $relObj) { + foreach ($this->getFeatureCategories() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addFeatureCategory($relObj->copy($deepCopy)); } @@ -1259,8 +1378,6 @@ abstract class BaseFeature extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1277,8 +1394,8 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Feature Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1291,46 +1408,28 @@ abstract class BaseFeature extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('FeatureAv' == $relationName) { - $this->initFeatureAvs(); + return $this->initFeatureAvs(); } if ('FeatureProd' == $relationName) { - $this->initFeatureProds(); + return $this->initFeatureProds(); } if ('FeatureCategory' == $relationName) { - $this->initFeatureCategorys(); + return $this->initFeatureCategories(); } if ('FeatureI18n' == $relationName) { - $this->initFeatureI18ns(); + return $this->initFeatureI18ns(); } } @@ -1340,21 +1439,16 @@ abstract class BaseFeature extends BaseObject implements Persistent * This 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) + * @return void * @see addFeatureAvs() */ public function clearFeatureAvs() { - $this->collFeatureAvs = null; // important to set this to null since that means it is uninitialized - $this->collFeatureAvsPartial = null; - - return $this; + $this->collFeatureAvs = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collFeatureAvs collection loaded partially - * - * @return void + * Reset is the collFeatureAvs collection loaded partially. */ public function resetPartialFeatureAvs($v = true) { @@ -1368,7 +1462,7 @@ abstract class BaseFeature extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1378,25 +1472,25 @@ abstract class BaseFeature extends BaseObject implements Persistent if (null !== $this->collFeatureAvs && !$overrideExisting) { return; } - $this->collFeatureAvs = new PropelObjectCollection(); - $this->collFeatureAvs->setModel('FeatureAv'); + $this->collFeatureAvs = new ObjectCollection(); + $this->collFeatureAvs->setModel('\Thelia\Model\FeatureAv'); } /** - * Gets an array of FeatureAv objects which contain a foreign key that references this object. + * Gets an array of ChildFeatureAv objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFeature is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFeatureAv[] List of ChildFeatureAv objects * @throws PropelException */ - public function getFeatureAvs($criteria = null, PropelPDO $con = null) + public function getFeatureAvs($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureAvsPartial && !$this->isNew(); if (null === $this->collFeatureAvs || null !== $criteria || $partial) { @@ -1404,29 +1498,31 @@ abstract class BaseFeature extends BaseObject implements Persistent // return empty collection $this->initFeatureAvs(); } else { - $collFeatureAvs = FeatureAvQuery::create(null, $criteria) + $collFeatureAvs = ChildFeatureAvQuery::create(null, $criteria) ->filterByFeature($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collFeatureAvsPartial && count($collFeatureAvs)) { - $this->initFeatureAvs(false); + $this->initFeatureAvs(false); - foreach($collFeatureAvs as $obj) { - if (false == $this->collFeatureAvs->contains($obj)) { - $this->collFeatureAvs->append($obj); + foreach ($collFeatureAvs as $obj) { + if (false == $this->collFeatureAvs->contains($obj)) { + $this->collFeatureAvs->append($obj); + } } - } - $this->collFeatureAvsPartial = true; + $this->collFeatureAvsPartial = true; } $collFeatureAvs->getInternalIterator()->rewind(); + return $collFeatureAvs; } - if($partial && $this->collFeatureAvs) { - foreach($this->collFeatureAvs as $obj) { - if($obj->isNew()) { + if ($partial && $this->collFeatureAvs) { + foreach ($this->collFeatureAvs as $obj) { + if ($obj->isNew()) { $collFeatureAvs[] = $obj; } } @@ -1446,15 +1542,16 @@ abstract class BaseFeature extends BaseObject implements Persistent * It will 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) + * @param Collection $featureAvs A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFeature The current object (for fluent API support) */ - public function setFeatureAvs(PropelCollection $featureAvs, PropelPDO $con = null) + public function setFeatureAvs(Collection $featureAvs, ConnectionInterface $con = null) { $featureAvsToDelete = $this->getFeatureAvs(new Criteria(), $con)->diff($featureAvs); - $this->featureAvsScheduledForDeletion = unserialize(serialize($featureAvsToDelete)); + + $this->featureAvsScheduledForDeletion = $featureAvsToDelete; foreach ($featureAvsToDelete as $featureAvRemoved) { $featureAvRemoved->setFeature(null); @@ -1474,13 +1571,13 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Returns the number of related FeatureAv objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FeatureAv objects. * @throws PropelException */ - public function countFeatureAvs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFeatureAvs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureAvsPartial && !$this->isNew(); if (null === $this->collFeatureAvs || null !== $criteria || $partial) { @@ -1488,10 +1585,11 @@ abstract class BaseFeature extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getFeatureAvs()); } - $query = FeatureAvQuery::create(null, $criteria); + + $query = ChildFeatureAvQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1505,18 +1603,19 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * Method called to associate a FeatureAv object to this object - * through the FeatureAv foreign key attribute. + * Method called to associate a ChildFeatureAv object to this object + * through the ChildFeatureAv foreign key attribute. * - * @param FeatureAv $l FeatureAv - * @return Feature The current object (for fluent API support) + * @param ChildFeatureAv $l ChildFeatureAv + * @return \Thelia\Model\Feature The current object (for fluent API support) */ - public function addFeatureAv(FeatureAv $l) + public function addFeatureAv(ChildFeatureAv $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); } @@ -1525,7 +1624,7 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * @param FeatureAv $featureAv The featureAv object to add. + * @param FeatureAv $featureAv The featureAv object to add. */ protected function doAddFeatureAv($featureAv) { @@ -1534,8 +1633,8 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * @param FeatureAv $featureAv The featureAv object to remove. - * @return Feature The current object (for fluent API support) + * @param FeatureAv $featureAv The featureAv object to remove. + * @return ChildFeature The current object (for fluent API support) */ public function removeFeatureAv($featureAv) { @@ -1558,21 +1657,16 @@ abstract class BaseFeature extends BaseObject implements Persistent * This 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) + * @return void * @see addFeatureProds() */ public function clearFeatureProds() { - $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized - $this->collFeatureProdsPartial = null; - - return $this; + $this->collFeatureProds = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collFeatureProds collection loaded partially - * - * @return void + * Reset is the collFeatureProds collection loaded partially. */ public function resetPartialFeatureProds($v = true) { @@ -1586,7 +1680,7 @@ abstract class BaseFeature extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1596,25 +1690,25 @@ abstract class BaseFeature extends BaseObject implements Persistent if (null !== $this->collFeatureProds && !$overrideExisting) { return; } - $this->collFeatureProds = new PropelObjectCollection(); - $this->collFeatureProds->setModel('FeatureProd'); + $this->collFeatureProds = new ObjectCollection(); + $this->collFeatureProds->setModel('\Thelia\Model\FeatureProd'); } /** - * Gets an array of FeatureProd objects which contain a foreign key that references this object. + * Gets an array of ChildFeatureProd objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFeature is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects * @throws PropelException */ - public function getFeatureProds($criteria = null, PropelPDO $con = null) + public function getFeatureProds($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureProdsPartial && !$this->isNew(); if (null === $this->collFeatureProds || null !== $criteria || $partial) { @@ -1622,29 +1716,31 @@ abstract class BaseFeature extends BaseObject implements Persistent // return empty collection $this->initFeatureProds(); } else { - $collFeatureProds = FeatureProdQuery::create(null, $criteria) + $collFeatureProds = ChildFeatureProdQuery::create(null, $criteria) ->filterByFeature($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { - $this->initFeatureProds(false); + $this->initFeatureProds(false); - foreach($collFeatureProds as $obj) { - if (false == $this->collFeatureProds->contains($obj)) { - $this->collFeatureProds->append($obj); + foreach ($collFeatureProds as $obj) { + if (false == $this->collFeatureProds->contains($obj)) { + $this->collFeatureProds->append($obj); + } } - } - $this->collFeatureProdsPartial = true; + $this->collFeatureProdsPartial = true; } $collFeatureProds->getInternalIterator()->rewind(); + return $collFeatureProds; } - if($partial && $this->collFeatureProds) { - foreach($this->collFeatureProds as $obj) { - if($obj->isNew()) { + if ($partial && $this->collFeatureProds) { + foreach ($this->collFeatureProds as $obj) { + if ($obj->isNew()) { $collFeatureProds[] = $obj; } } @@ -1664,15 +1760,16 @@ abstract class BaseFeature extends BaseObject implements Persistent * It will 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) + * @param Collection $featureProds A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFeature The current object (for fluent API support) */ - public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) + public function setFeatureProds(Collection $featureProds, ConnectionInterface $con = null) { $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete)); + + $this->featureProdsScheduledForDeletion = $featureProdsToDelete; foreach ($featureProdsToDelete as $featureProdRemoved) { $featureProdRemoved->setFeature(null); @@ -1692,13 +1789,13 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Returns the number of related FeatureProd objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FeatureProd objects. * @throws PropelException */ - public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFeatureProds(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureProdsPartial && !$this->isNew(); if (null === $this->collFeatureProds || null !== $criteria || $partial) { @@ -1706,10 +1803,11 @@ abstract class BaseFeature extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getFeatureProds()); } - $query = FeatureProdQuery::create(null, $criteria); + + $query = ChildFeatureProdQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1723,18 +1821,19 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * Method called to associate a FeatureProd object to this object - * through the FeatureProd foreign key attribute. + * Method called to associate a ChildFeatureProd object to this object + * through the ChildFeatureProd foreign key attribute. * - * @param FeatureProd $l FeatureProd - * @return Feature The current object (for fluent API support) + * @param ChildFeatureProd $l ChildFeatureProd + * @return \Thelia\Model\Feature The current object (for fluent API support) */ - public function addFeatureProd(FeatureProd $l) + public function addFeatureProd(ChildFeatureProd $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); } @@ -1743,7 +1842,7 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * @param FeatureProd $featureProd The featureProd object to add. + * @param FeatureProd $featureProd The featureProd object to add. */ protected function doAddFeatureProd($featureProd) { @@ -1752,8 +1851,8 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * @param FeatureProd $featureProd The featureProd object to remove. - * @return Feature The current object (for fluent API support) + * @param FeatureProd $featureProd The featureProd object to remove. + * @return ChildFeature The current object (for fluent API support) */ public function removeFeatureProd($featureProd) { @@ -1782,15 +1881,15 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects */ - public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureProdsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildFeatureProdQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getFeatureProds($query, $con); } @@ -1807,123 +1906,120 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects */ - public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('FeatureAv', $join_behavior); + $query = ChildFeatureProdQuery::create(null, $criteria); + $query->joinWith('FeatureAv', $joinBehavior); return $this->getFeatureProds($query, $con); } /** - * Clears out the collFeatureCategorys collection + * Clears out the collFeatureCategories collection * * This 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 + * @see addFeatureCategories() */ - public function resetPartialFeatureCategorys($v = true) + public function clearFeatureCategories() { - $this->collFeatureCategorysPartial = $v; + $this->collFeatureCategories = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collFeatureCategorys collection. + * Reset is the collFeatureCategories collection loaded partially. + */ + public function resetPartialFeatureCategories($v = true) + { + $this->collFeatureCategoriesPartial = $v; + } + + /** + * Initializes the collFeatureCategories collection. * - * By default this just sets the collFeatureCategorys collection to an empty array (like clearcollFeatureCategorys()); + * By default this just sets the collFeatureCategories collection to an empty array (like clearcollFeatureCategories()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initFeatureCategories($overrideExisting = true) { - if (null !== $this->collFeatureCategorys && !$overrideExisting) { + if (null !== $this->collFeatureCategories && !$overrideExisting) { return; } - $this->collFeatureCategorys = new PropelObjectCollection(); - $this->collFeatureCategorys->setModel('FeatureCategory'); + $this->collFeatureCategories = new ObjectCollection(); + $this->collFeatureCategories->setModel('\Thelia\Model\FeatureCategory'); } /** - * Gets an array of FeatureCategory objects which contain a foreign key that references this object. + * Gets an array of ChildFeatureCategory objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFeature is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects * @throws PropelException */ - public function getFeatureCategorys($criteria = null, PropelPDO $con = null) + public function getFeatureCategories($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategorys) { + $partial = $this->collFeatureCategoriesPartial && !$this->isNew(); + if (null === $this->collFeatureCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureCategories) { // return empty collection - $this->initFeatureCategorys(); + $this->initFeatureCategories(); } else { - $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria) + $collFeatureCategories = ChildFeatureCategoryQuery::create(null, $criteria) ->filterByFeature($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) { - $this->initFeatureCategorys(false); + if (false !== $this->collFeatureCategoriesPartial && count($collFeatureCategories)) { + $this->initFeatureCategories(false); - foreach($collFeatureCategorys as $obj) { - if (false == $this->collFeatureCategorys->contains($obj)) { - $this->collFeatureCategorys->append($obj); + foreach ($collFeatureCategories as $obj) { + if (false == $this->collFeatureCategories->contains($obj)) { + $this->collFeatureCategories->append($obj); + } } - } - $this->collFeatureCategorysPartial = true; + $this->collFeatureCategoriesPartial = true; } - $collFeatureCategorys->getInternalIterator()->rewind(); - return $collFeatureCategorys; + $collFeatureCategories->getInternalIterator()->rewind(); + + return $collFeatureCategories; } - if($partial && $this->collFeatureCategorys) { - foreach($this->collFeatureCategorys as $obj) { - if($obj->isNew()) { - $collFeatureCategorys[] = $obj; + if ($partial && $this->collFeatureCategories) { + foreach ($this->collFeatureCategories as $obj) { + if ($obj->isNew()) { + $collFeatureCategories[] = $obj; } } } - $this->collFeatureCategorys = $collFeatureCategorys; - $this->collFeatureCategorysPartial = false; + $this->collFeatureCategories = $collFeatureCategories; + $this->collFeatureCategoriesPartial = false; } } - return $this->collFeatureCategorys; + return $this->collFeatureCategories; } /** @@ -1932,27 +2028,28 @@ abstract class BaseFeature extends BaseObject implements Persistent * It will 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) + * @param Collection $featureCategories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFeature The current object (for fluent API support) */ - public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null) + public function setFeatureCategories(Collection $featureCategories, ConnectionInterface $con = null) { - $featureCategorysToDelete = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); + $featureCategoriesToDelete = $this->getFeatureCategories(new Criteria(), $con)->diff($featureCategories); - $this->featureCategorysScheduledForDeletion = unserialize(serialize($featureCategorysToDelete)); - foreach ($featureCategorysToDelete as $featureCategoryRemoved) { + $this->featureCategoriesScheduledForDeletion = $featureCategoriesToDelete; + + foreach ($featureCategoriesToDelete as $featureCategoryRemoved) { $featureCategoryRemoved->setFeature(null); } - $this->collFeatureCategorys = null; - foreach ($featureCategorys as $featureCategory) { + $this->collFeatureCategories = null; + foreach ($featureCategories as $featureCategory) { $this->addFeatureCategory($featureCategory); } - $this->collFeatureCategorys = $featureCategorys; - $this->collFeatureCategorysPartial = false; + $this->collFeatureCategories = $featureCategories; + $this->collFeatureCategoriesPartial = false; return $this; } @@ -1960,24 +2057,25 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Returns the number of related FeatureCategory objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FeatureCategory objects. * @throws PropelException */ - public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFeatureCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategorys) { + $partial = $this->collFeatureCategoriesPartial && !$this->isNew(); + if (null === $this->collFeatureCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collFeatureCategories) { return 0; } - if($partial && !$criteria) { - return count($this->getFeatureCategorys()); + if ($partial && !$criteria) { + return count($this->getFeatureCategories()); } - $query = FeatureCategoryQuery::create(null, $criteria); + + $query = ChildFeatureCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1987,23 +2085,24 @@ abstract class BaseFeature extends BaseObject implements Persistent ->count($con); } - return count($this->collFeatureCategorys); + return count($this->collFeatureCategories); } /** - * Method called to associate a FeatureCategory object to this object - * through the FeatureCategory foreign key attribute. + * Method called to associate a ChildFeatureCategory object to this object + * through the ChildFeatureCategory foreign key attribute. * - * @param FeatureCategory $l FeatureCategory - * @return Feature The current object (for fluent API support) + * @param ChildFeatureCategory $l ChildFeatureCategory + * @return \Thelia\Model\Feature The current object (for fluent API support) */ - public function addFeatureCategory(FeatureCategory $l) + public function addFeatureCategory(ChildFeatureCategory $l) { - if ($this->collFeatureCategorys === null) { - $this->initFeatureCategorys(); - $this->collFeatureCategorysPartial = true; + if ($this->collFeatureCategories === null) { + $this->initFeatureCategories(); + $this->collFeatureCategoriesPartial = true; } - if (!in_array($l, $this->collFeatureCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collFeatureCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureCategory($l); } @@ -2011,27 +2110,27 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * @param FeatureCategory $featureCategory The featureCategory object to add. + * @param FeatureCategory $featureCategory The featureCategory object to add. */ protected function doAddFeatureCategory($featureCategory) { - $this->collFeatureCategorys[]= $featureCategory; + $this->collFeatureCategories[]= $featureCategory; $featureCategory->setFeature($this); } /** - * @param FeatureCategory $featureCategory The featureCategory object to remove. - * @return Feature The current object (for fluent API support) + * @param FeatureCategory $featureCategory The featureCategory object to remove. + * @return ChildFeature 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(); + if ($this->getFeatureCategories()->contains($featureCategory)) { + $this->collFeatureCategories->remove($this->collFeatureCategories->search($featureCategory)); + if (null === $this->featureCategoriesScheduledForDeletion) { + $this->featureCategoriesScheduledForDeletion = clone $this->collFeatureCategories; + $this->featureCategoriesScheduledForDeletion->clear(); } - $this->featureCategorysScheduledForDeletion[]= clone $featureCategory; + $this->featureCategoriesScheduledForDeletion[]= clone $featureCategory; $featureCategory->setFeature(null); } @@ -2044,23 +2143,23 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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. + * been saved, it will retrieve related FeatureCategories from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildFeatureCategory[] List of ChildFeatureCategory objects */ - public function getFeatureCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = FeatureCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildFeatureCategoryQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); - return $this->getFeatureCategorys($query, $con); + return $this->getFeatureCategories($query, $con); } /** @@ -2069,21 +2168,16 @@ abstract class BaseFeature extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collFeatureI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collFeatureI18ns collection loaded partially - * - * @return void + * Reset is the collFeatureI18ns collection loaded partially. */ public function resetPartialFeatureI18ns($v = true) { @@ -2097,7 +2191,7 @@ abstract class BaseFeature extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2107,25 +2201,25 @@ abstract class BaseFeature extends BaseObject implements Persistent if (null !== $this->collFeatureI18ns && !$overrideExisting) { return; } - $this->collFeatureI18ns = new PropelObjectCollection(); - $this->collFeatureI18ns->setModel('FeatureI18n'); + $this->collFeatureI18ns = new ObjectCollection(); + $this->collFeatureI18ns->setModel('\Thelia\Model\FeatureI18n'); } /** - * Gets an array of FeatureI18n objects which contain a foreign key that references this object. + * Gets an array of ChildFeatureI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFeature is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFeatureI18n[] List of ChildFeatureI18n objects * @throws PropelException */ - public function getFeatureI18ns($criteria = null, PropelPDO $con = null) + public function getFeatureI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureI18nsPartial && !$this->isNew(); if (null === $this->collFeatureI18ns || null !== $criteria || $partial) { @@ -2133,29 +2227,31 @@ abstract class BaseFeature extends BaseObject implements Persistent // return empty collection $this->initFeatureI18ns(); } else { - $collFeatureI18ns = FeatureI18nQuery::create(null, $criteria) + $collFeatureI18ns = ChildFeatureI18nQuery::create(null, $criteria) ->filterByFeature($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collFeatureI18nsPartial && count($collFeatureI18ns)) { - $this->initFeatureI18ns(false); + $this->initFeatureI18ns(false); - foreach($collFeatureI18ns as $obj) { - if (false == $this->collFeatureI18ns->contains($obj)) { - $this->collFeatureI18ns->append($obj); + foreach ($collFeatureI18ns as $obj) { + if (false == $this->collFeatureI18ns->contains($obj)) { + $this->collFeatureI18ns->append($obj); + } } - } - $this->collFeatureI18nsPartial = true; + $this->collFeatureI18nsPartial = true; } $collFeatureI18ns->getInternalIterator()->rewind(); + return $collFeatureI18ns; } - if($partial && $this->collFeatureI18ns) { - foreach($this->collFeatureI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collFeatureI18ns) { + foreach ($this->collFeatureI18ns as $obj) { + if ($obj->isNew()) { $collFeatureI18ns[] = $obj; } } @@ -2175,15 +2271,19 @@ abstract class BaseFeature extends BaseObject implements Persistent * It will 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) + * @param Collection $featureI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFeature The current object (for fluent API support) */ - public function setFeatureI18ns(PropelCollection $featureI18ns, PropelPDO $con = null) + public function setFeatureI18ns(Collection $featureI18ns, ConnectionInterface $con = null) { $featureI18nsToDelete = $this->getFeatureI18ns(new Criteria(), $con)->diff($featureI18ns); - $this->featureI18nsScheduledForDeletion = unserialize(serialize($featureI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->featureI18nsScheduledForDeletion = clone $featureI18nsToDelete; foreach ($featureI18nsToDelete as $featureI18nRemoved) { $featureI18nRemoved->setFeature(null); @@ -2203,13 +2303,13 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Returns the number of related FeatureI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FeatureI18n objects. * @throws PropelException */ - public function countFeatureI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFeatureI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureI18nsPartial && !$this->isNew(); if (null === $this->collFeatureI18ns || null !== $criteria || $partial) { @@ -2217,10 +2317,11 @@ abstract class BaseFeature extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getFeatureI18ns()); } - $query = FeatureI18nQuery::create(null, $criteria); + + $query = ChildFeatureI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2234,13 +2335,13 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * Method called to associate a FeatureI18n object to this object - * through the FeatureI18n foreign key attribute. + * Method called to associate a ChildFeatureI18n object to this object + * through the ChildFeatureI18n foreign key attribute. * - * @param FeatureI18n $l FeatureI18n - * @return Feature The current object (for fluent API support) + * @param ChildFeatureI18n $l ChildFeatureI18n + * @return \Thelia\Model\Feature The current object (for fluent API support) */ - public function addFeatureI18n(FeatureI18n $l) + public function addFeatureI18n(ChildFeatureI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -2250,6 +2351,7 @@ abstract class BaseFeature extends BaseObject implements Persistent $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); } @@ -2258,7 +2360,7 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * @param FeatureI18n $featureI18n The featureI18n object to add. + * @param FeatureI18n $featureI18n The featureI18n object to add. */ protected function doAddFeatureI18n($featureI18n) { @@ -2267,8 +2369,8 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * @param FeatureI18n $featureI18n The featureI18n object to remove. - * @return Feature The current object (for fluent API support) + * @param FeatureI18n $featureI18n The featureI18n object to remove. + * @return ChildFeature The current object (for fluent API support) */ public function removeFeatureI18n($featureI18n) { @@ -2286,70 +2388,68 @@ abstract class BaseFeature extends BaseObject implements Persistent } /** - * Clears out the collCategorys collection + * Clears out the collCategories collection * * This 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() + * @return void + * @see addCategories() */ - public function clearCategorys() + public function clearCategories() { - $this->collCategorys = null; // important to set this to null since that means it is uninitialized - $this->collCategorysPartial = null; - - return $this; + $this->collCategories = null; // important to set this to NULL since that means it is uninitialized + $this->collCategoriesPartial = null; } /** - * Initializes the collCategorys collection. + * Initializes the collCategories collection. * - * By default this just sets the collCategorys collection to an empty collection (like clearCategorys()); + * By default this just sets the collCategories collection to an empty collection (like clearCategories()); * however, you may wish to override this 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() + public function initCategories() { - $this->collCategorys = new PropelObjectCollection(); - $this->collCategorys->setModel('Category'); + $this->collCategories = new ObjectCollection(); + $this->collCategories->setModel('\Thelia\Model\Category'); } /** - * Gets a collection of Category objects related by a many-to-many relationship + * Gets a collection of ChildCategory 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 + * If this ChildFeature 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Category[] List of Category objects + * @return ObjectCollection|ChildCategory[] List of ChildCategory objects */ - public function getCategorys($criteria = null, PropelPDO $con = null) + public function getCategories($criteria = null, ConnectionInterface $con = null) { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { + if (null === $this->collCategories || null !== $criteria) { + if ($this->isNew() && null === $this->collCategories) { // return empty collection - $this->initCategorys(); + $this->initCategories(); } else { - $collCategorys = CategoryQuery::create(null, $criteria) + $collCategories = ChildCategoryQuery::create(null, $criteria) ->filterByFeature($this) ->find($con); if (null !== $criteria) { - return $collCategorys; + return $collCategories; } - $this->collCategorys = $collCategorys; + $this->collCategories = $collCategories; } } - return $this->collCategorys; + return $this->collCategories; } /** @@ -2358,45 +2458,45 @@ abstract class BaseFeature extends BaseObject implements Persistent * It will 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) + * @param Collection $categories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFeature The current object (for fluent API support) */ - public function setCategorys(PropelCollection $categorys, PropelPDO $con = null) + public function setCategories(Collection $categories, ConnectionInterface $con = null) { - $this->clearCategorys(); - $currentCategorys = $this->getCategorys(); + $this->clearCategories(); + $currentCategories = $this->getCategories(); - $this->categorysScheduledForDeletion = $currentCategorys->diff($categorys); + $this->categoriesScheduledForDeletion = $currentCategories->diff($categories); - foreach ($categorys as $category) { - if (!$currentCategorys->contains($category)) { + foreach ($categories as $category) { + if (!$currentCategories->contains($category)) { $this->doAddCategory($category); } } - $this->collCategorys = $categorys; + $this->collCategories = $categories; return $this; } /** - * Gets the number of Category objects related by a many-to-many relationship + * Gets the number of ChildCategory 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Category objects + * @return int the number of related ChildCategory objects */ - public function countCategorys($criteria = null, $distinct = false, PropelPDO $con = null) + public function countCategories($criteria = null, $distinct = false, ConnectionInterface $con = null) { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { + if (null === $this->collCategories || null !== $criteria) { + if ($this->isNew() && null === $this->collCategories) { return 0; } else { - $query = CategoryQuery::create(null, $criteria); + $query = ChildCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2406,57 +2506,65 @@ abstract class BaseFeature extends BaseObject implements Persistent ->count($con); } } else { - return count($this->collCategorys); + return count($this->collCategories); } } /** - * Associate a Category object to this object + * Associate a ChildCategory 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) + * @param ChildCategory $category The ChildFeatureCategory object to relate + * @return ChildFeature The current object (for fluent API support) */ - public function addCategory(Category $category) + public function addCategory(ChildCategory $category) { - if ($this->collCategorys === null) { - $this->initCategorys(); + if ($this->collCategories === null) { + $this->initCategories(); } - if (!$this->collCategorys->contains($category)) { // only add it if the **same** object is not already associated - $this->doAddCategory($category); - $this->collCategorys[]= $category; + if (!$this->collCategories->contains($category)) { // only add it if the **same** object is not already associated + $this->doAddCategory($category); + $this->collCategories[] = $category; } return $this; } /** - * @param Category $category The category object to add. + * @param Category $category The category object to add. */ protected function doAddCategory($category) { - $featureCategory = new FeatureCategory(); + $featureCategory = new ChildFeatureCategory(); $featureCategory->setCategory($category); $this->addFeatureCategory($featureCategory); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$category->getFeatures()->contains($this)) { + $foreignCollection = $category->getFeatures(); + $foreignCollection[] = $this; + } } /** - * Remove a Category object to this object + * Remove a ChildCategory 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) + * @param ChildCategory $category The ChildFeatureCategory object to relate + * @return ChildFeature The current object (for fluent API support) */ - public function removeCategory(Category $category) + public function removeCategory(ChildCategory $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(); + if ($this->getCategories()->contains($category)) { + $this->collCategories->remove($this->collCategories->search($category)); + + if (null === $this->categoriesScheduledForDeletion) { + $this->categoriesScheduledForDeletion = clone $this->collCategories; + $this->categoriesScheduledForDeletion->clear(); } - $this->categorysScheduledForDeletion[]= $category; + + $this->categoriesScheduledForDeletion[] = $category; } return $this; @@ -2473,8 +2581,6 @@ abstract class BaseFeature extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); @@ -2487,14 +2593,13 @@ abstract class BaseFeature extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collFeatureAvs) { foreach ($this->collFeatureAvs as $o) { $o->clearAllReferences($deep); @@ -2505,8 +2610,8 @@ abstract class BaseFeature extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->collFeatureCategorys) { - foreach ($this->collFeatureCategorys as $o) { + if ($this->collFeatureCategories) { + foreach ($this->collFeatureCategories as $o) { $o->clearAllReferences($deep); } } @@ -2515,59 +2620,47 @@ abstract class BaseFeature extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->collCategorys) { - foreach ($this->collCategorys as $o) { + if ($this->collCategories) { + foreach ($this->collCategories as $o) { $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collFeatureAvs instanceof PropelCollection) { + if ($this->collFeatureAvs instanceof Collection) { $this->collFeatureAvs->clearIterator(); } $this->collFeatureAvs = null; - if ($this->collFeatureProds instanceof PropelCollection) { + if ($this->collFeatureProds instanceof Collection) { $this->collFeatureProds->clearIterator(); } $this->collFeatureProds = null; - if ($this->collFeatureCategorys instanceof PropelCollection) { - $this->collFeatureCategorys->clearIterator(); + if ($this->collFeatureCategories instanceof Collection) { + $this->collFeatureCategories->clearIterator(); } - $this->collFeatureCategorys = null; - if ($this->collFeatureI18ns instanceof PropelCollection) { + $this->collFeatureCategories = null; + if ($this->collFeatureI18ns instanceof Collection) { $this->collFeatureI18ns->clearIterator(); } $this->collFeatureI18ns = null; - if ($this->collCategorys instanceof PropelCollection) { - $this->collCategorys->clearIterator(); + if ($this->collCategories instanceof Collection) { + $this->collCategories->clearIterator(); } - $this->collCategorys = null; + $this->collCategories = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(FeatureTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2575,11 +2668,11 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * 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) + * @return ChildFeature The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = FeaturePeer::UPDATED_AT; + $this->modifiedColumns[] = FeatureTableMap::UPDATED_AT; return $this; } @@ -2591,9 +2684,9 @@ abstract class BaseFeature extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Feature The current object (for fluent API support) + * @return ChildFeature The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2614,10 +2707,10 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return FeatureI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildFeatureI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureI18ns) { @@ -2630,10 +2723,10 @@ abstract class BaseFeature extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new FeatureI18n(); + $translation = new ChildFeatureI18n(); $translation->setLocale($locale); } else { - $translation = FeatureI18nQuery::create() + $translation = ChildFeatureI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -2648,14 +2741,14 @@ abstract class BaseFeature extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Feature The current object (for fluent API support) + * @return ChildFeature The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - FeatureI18nQuery::create() + ChildFeatureI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -2675,10 +2768,10 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return FeatureI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildFeatureI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -2687,7 +2780,7 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -2698,8 +2791,8 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FeatureI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2711,7 +2804,7 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -2722,8 +2815,8 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FeatureI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2735,7 +2828,7 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -2746,8 +2839,8 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FeatureI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2759,7 +2852,7 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -2770,8 +2863,8 @@ abstract class BaseFeature extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FeatureI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -2779,4 +2872,122 @@ abstract class BaseFeature extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseFeatureAv.php b/core/lib/Thelia/Model/Base/FeatureAv.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseFeatureAv.php rename to core/lib/Thelia/Model/Base/FeatureAv.php index adaffcd44..baa930702 --- a/core/lib/Thelia/Model/om/BaseFeatureAv.php +++ b/core/lib/Thelia/Model/Base/FeatureAv.php @@ -1,57 +1,65 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FeatureAv instance. If + * obj is an instance of FeatureAv, delegates to + * equals(FeatureAv). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FeatureAv The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FeatureAv The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [feature_id] column value. * - * @return int + * @return int */ public function getFeatureId() { + return $this->feature_id; } @@ -164,97 +416,57 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\FeatureAv The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = FeatureAvPeer::ID; + $this->modifiedColumns[] = FeatureAvTableMap::ID; } @@ -264,18 +476,18 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Set the value of [feature_id] column. * - * @param int $v new value - * @return FeatureAv The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\FeatureAv The current object (for fluent API support) */ public function setFeatureId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->feature_id !== $v) { $this->feature_id = $v; - $this->modifiedColumns[] = FeatureAvPeer::FEATURE_ID; + $this->modifiedColumns[] = FeatureAvTableMap::FEATURE_ID; } if ($this->aFeature !== null && $this->aFeature->getId() !== $v) { @@ -289,19 +501,17 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\FeatureAv The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = FeatureAvTableMap::CREATED_AT; } } // if either are not null @@ -312,19 +522,17 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\FeatureAv The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = FeatureAvTableMap::UPDATED_AT; } } // if either are not null @@ -342,7 +550,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -354,20 +562,38 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureAvTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureAvTableMap::translateFieldName('FeatureId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->feature_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureAvTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureAvTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -375,11 +601,11 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = FeatureAvPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 4; // 4 = FeatureAvTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating FeatureAv object", $e); + throw new PropelException("Error populating \Thelia\Model\FeatureAv object", 0, $e); } } @@ -398,7 +624,6 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) { $this->aFeature = null; } @@ -409,12 +634,12 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -425,19 +650,19 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FeatureAvTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildFeatureAvQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -452,26 +677,25 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see FeatureAv::setDeleted() + * @see FeatureAv::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = FeatureAvQuery::create() + $deleteQuery = ChildFeatureAvQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -496,20 +720,19 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -519,16 +742,16 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(FeatureAvPeer::CREATED_AT)) { + if (!$this->isColumnModified(FeatureAvTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(FeatureAvPeer::UPDATED_AT)) { + if (!$this->isColumnModified(FeatureAvTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FeatureAvPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(FeatureAvTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -540,7 +763,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - FeatureAvPeer::addInstanceToPool($this); + FeatureAvTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -559,19 +782,19 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -595,16 +818,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent 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); - } + \Thelia\Model\FeatureProdQuery::create() + ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->featureProdsScheduledForDeletion = null; } } - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { + if ($this->collFeatureProds !== null) { + foreach ($this->collFeatureProds as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -613,15 +835,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if ($this->featureAvI18nsScheduledForDeletion !== null) { if (!$this->featureAvI18nsScheduledForDeletion->isEmpty()) { - FeatureAvI18nQuery::create() + \Thelia\Model\FeatureAvI18nQuery::create() ->filterByPrimaryKeys($this->featureAvI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->featureAvI18nsScheduledForDeletion = null; } } - if ($this->collFeatureAvI18ns !== null) { - foreach ($this->collFeatureAvI18ns as $referrerFK) { + if ($this->collFeatureAvI18ns !== null) { + foreach ($this->collFeatureAvI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -638,37 +860,37 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = FeatureAvPeer::ID; + $this->modifiedColumns[] = FeatureAvTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureAvPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureAvTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeatureAvPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(FeatureAvTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(FeatureAvPeer::FEATURE_ID)) { - $modifiedColumns[':p' . $index++] = '`feature_id`'; + if ($this->isColumnModified(FeatureAvTableMap::FEATURE_ID)) { + $modifiedColumns[':p' . $index++] = 'FEATURE_ID'; } - if ($this->isColumnModified(FeatureAvPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(FeatureAvTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(FeatureAvPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(FeatureAvTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `feature_av` (%s) VALUES (%s)', + 'INSERT INTO feature_av (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -677,30 +899,30 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`feature_id`': + 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); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -710,132 +932,32 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = FeatureAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = FeatureAvTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -845,7 +967,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -875,28 +997,34 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = FeatureAvTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getFeatureId(), $keys[2] => $this->getCreatedAt(), $keys[3] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aFeature) { $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -915,27 +1043,27 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = FeatureAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = FeatureAvTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -965,17 +1093,17 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = FeatureAvPeer::getFieldNames($keyType); + $keys = FeatureAvTableMap::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]]); @@ -990,12 +1118,12 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME); + $criteria = new Criteria(FeatureAvTableMap::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); + if ($this->isColumnModified(FeatureAvTableMap::ID)) $criteria->add(FeatureAvTableMap::ID, $this->id); + if ($this->isColumnModified(FeatureAvTableMap::FEATURE_ID)) $criteria->add(FeatureAvTableMap::FEATURE_ID, $this->feature_id); + if ($this->isColumnModified(FeatureAvTableMap::CREATED_AT)) $criteria->add(FeatureAvTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FeatureAvTableMap::UPDATED_AT)) $criteria->add(FeatureAvTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1010,15 +1138,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME); - $criteria->add(FeatureAvPeer::ID, $this->id); + $criteria = new Criteria(FeatureAvTableMap::DATABASE_NAME); + $criteria->add(FeatureAvTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1028,7 +1156,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1052,9 +1180,9 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1063,12 +1191,10 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1082,8 +1208,6 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1100,8 +1224,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\FeatureAv Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1115,31 +1239,13 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildFeature object. * - * 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) + * @param ChildFeature $v + * @return \Thelia\Model\FeatureAv The current object (for fluent API support) * @throws PropelException */ - public function setFeature(Feature $v = null) + public function setFeature(ChildFeature $v = null) { if ($v === null) { $this->setFeatureId(NULL); @@ -1150,7 +1256,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $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 this object has already been added to the ChildFeature object, it will not be re-added. if ($v !== null) { $v->addFeatureAv($this); } @@ -1161,17 +1267,16 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** - * Get the associated Feature object + * Get the associated ChildFeature object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Feature The associated Feature object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFeature The associated ChildFeature object. * @throws PropelException */ - public function getFeature(PropelPDO $con = null, $doQuery = true) + public function getFeature(ConnectionInterface $con = null) { - if ($this->aFeature === null && ($this->feature_id !== null) && $doQuery) { - $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con); + if ($this->aFeature === null && ($this->feature_id !== null)) { + $this->aFeature = ChildFeatureQuery::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 @@ -1190,16 +1295,16 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('FeatureProd' == $relationName) { - $this->initFeatureProds(); + return $this->initFeatureProds(); } if ('FeatureAvI18n' == $relationName) { - $this->initFeatureAvI18ns(); + return $this->initFeatureAvI18ns(); } } @@ -1209,21 +1314,16 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * This 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) + * @return void * @see addFeatureProds() */ public function clearFeatureProds() { - $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized - $this->collFeatureProdsPartial = null; - - return $this; + $this->collFeatureProds = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collFeatureProds collection loaded partially - * - * @return void + * Reset is the collFeatureProds collection loaded partially. */ public function resetPartialFeatureProds($v = true) { @@ -1237,7 +1337,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1247,25 +1347,25 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if (null !== $this->collFeatureProds && !$overrideExisting) { return; } - $this->collFeatureProds = new PropelObjectCollection(); - $this->collFeatureProds->setModel('FeatureProd'); + $this->collFeatureProds = new ObjectCollection(); + $this->collFeatureProds->setModel('\Thelia\Model\FeatureProd'); } /** - * Gets an array of FeatureProd objects which contain a foreign key that references this object. + * Gets an array of ChildFeatureProd objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFeatureAv is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects * @throws PropelException */ - public function getFeatureProds($criteria = null, PropelPDO $con = null) + public function getFeatureProds($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureProdsPartial && !$this->isNew(); if (null === $this->collFeatureProds || null !== $criteria || $partial) { @@ -1273,29 +1373,31 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent // return empty collection $this->initFeatureProds(); } else { - $collFeatureProds = FeatureProdQuery::create(null, $criteria) + $collFeatureProds = ChildFeatureProdQuery::create(null, $criteria) ->filterByFeatureAv($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { - $this->initFeatureProds(false); + $this->initFeatureProds(false); - foreach($collFeatureProds as $obj) { - if (false == $this->collFeatureProds->contains($obj)) { - $this->collFeatureProds->append($obj); + foreach ($collFeatureProds as $obj) { + if (false == $this->collFeatureProds->contains($obj)) { + $this->collFeatureProds->append($obj); + } } - } - $this->collFeatureProdsPartial = true; + $this->collFeatureProdsPartial = true; } $collFeatureProds->getInternalIterator()->rewind(); + return $collFeatureProds; } - if($partial && $this->collFeatureProds) { - foreach($this->collFeatureProds as $obj) { - if($obj->isNew()) { + if ($partial && $this->collFeatureProds) { + foreach ($this->collFeatureProds as $obj) { + if ($obj->isNew()) { $collFeatureProds[] = $obj; } } @@ -1315,15 +1417,16 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * It will 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) + * @param Collection $featureProds A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFeatureAv The current object (for fluent API support) */ - public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) + public function setFeatureProds(Collection $featureProds, ConnectionInterface $con = null) { $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete)); + + $this->featureProdsScheduledForDeletion = $featureProdsToDelete; foreach ($featureProdsToDelete as $featureProdRemoved) { $featureProdRemoved->setFeatureAv(null); @@ -1343,13 +1446,13 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Returns the number of related FeatureProd objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FeatureProd objects. * @throws PropelException */ - public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFeatureProds(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureProdsPartial && !$this->isNew(); if (null === $this->collFeatureProds || null !== $criteria || $partial) { @@ -1357,10 +1460,11 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getFeatureProds()); } - $query = FeatureProdQuery::create(null, $criteria); + + $query = ChildFeatureProdQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1374,18 +1478,19 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } /** - * Method called to associate a FeatureProd object to this object - * through the FeatureProd foreign key attribute. + * Method called to associate a ChildFeatureProd object to this object + * through the ChildFeatureProd foreign key attribute. * - * @param FeatureProd $l FeatureProd - * @return FeatureAv The current object (for fluent API support) + * @param ChildFeatureProd $l ChildFeatureProd + * @return \Thelia\Model\FeatureAv The current object (for fluent API support) */ - public function addFeatureProd(FeatureProd $l) + public function addFeatureProd(ChildFeatureProd $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); } @@ -1394,7 +1499,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } /** - * @param FeatureProd $featureProd The featureProd object to add. + * @param FeatureProd $featureProd The featureProd object to add. */ protected function doAddFeatureProd($featureProd) { @@ -1403,8 +1508,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } /** - * @param FeatureProd $featureProd The featureProd object to remove. - * @return FeatureAv The current object (for fluent API support) + * @param FeatureProd $featureProd The featureProd object to remove. + * @return ChildFeatureAv The current object (for fluent API support) */ public function removeFeatureProd($featureProd) { @@ -1433,15 +1538,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects */ - public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureProdsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildFeatureProdQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getFeatureProds($query, $con); } @@ -1458,15 +1563,15 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects */ - public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureProdsJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Feature', $join_behavior); + $query = ChildFeatureProdQuery::create(null, $criteria); + $query->joinWith('Feature', $joinBehavior); return $this->getFeatureProds($query, $con); } @@ -1477,21 +1582,16 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collFeatureAvI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collFeatureAvI18ns collection loaded partially - * - * @return void + * Reset is the collFeatureAvI18ns collection loaded partially. */ public function resetPartialFeatureAvI18ns($v = true) { @@ -1505,7 +1605,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1515,25 +1615,25 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent if (null !== $this->collFeatureAvI18ns && !$overrideExisting) { return; } - $this->collFeatureAvI18ns = new PropelObjectCollection(); - $this->collFeatureAvI18ns->setModel('FeatureAvI18n'); + $this->collFeatureAvI18ns = new ObjectCollection(); + $this->collFeatureAvI18ns->setModel('\Thelia\Model\FeatureAvI18n'); } /** - * Gets an array of FeatureAvI18n objects which contain a foreign key that references this object. + * Gets an array of ChildFeatureAvI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFeatureAv is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFeatureAvI18n[] List of ChildFeatureAvI18n objects * @throws PropelException */ - public function getFeatureAvI18ns($criteria = null, PropelPDO $con = null) + public function getFeatureAvI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureAvI18nsPartial && !$this->isNew(); if (null === $this->collFeatureAvI18ns || null !== $criteria || $partial) { @@ -1541,29 +1641,31 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent // return empty collection $this->initFeatureAvI18ns(); } else { - $collFeatureAvI18ns = FeatureAvI18nQuery::create(null, $criteria) + $collFeatureAvI18ns = ChildFeatureAvI18nQuery::create(null, $criteria) ->filterByFeatureAv($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collFeatureAvI18nsPartial && count($collFeatureAvI18ns)) { - $this->initFeatureAvI18ns(false); + $this->initFeatureAvI18ns(false); - foreach($collFeatureAvI18ns as $obj) { - if (false == $this->collFeatureAvI18ns->contains($obj)) { - $this->collFeatureAvI18ns->append($obj); + foreach ($collFeatureAvI18ns as $obj) { + if (false == $this->collFeatureAvI18ns->contains($obj)) { + $this->collFeatureAvI18ns->append($obj); + } } - } - $this->collFeatureAvI18nsPartial = true; + $this->collFeatureAvI18nsPartial = true; } $collFeatureAvI18ns->getInternalIterator()->rewind(); + return $collFeatureAvI18ns; } - if($partial && $this->collFeatureAvI18ns) { - foreach($this->collFeatureAvI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collFeatureAvI18ns) { + foreach ($this->collFeatureAvI18ns as $obj) { + if ($obj->isNew()) { $collFeatureAvI18ns[] = $obj; } } @@ -1583,15 +1685,19 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * It will 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) + * @param Collection $featureAvI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFeatureAv The current object (for fluent API support) */ - public function setFeatureAvI18ns(PropelCollection $featureAvI18ns, PropelPDO $con = null) + public function setFeatureAvI18ns(Collection $featureAvI18ns, ConnectionInterface $con = null) { $featureAvI18nsToDelete = $this->getFeatureAvI18ns(new Criteria(), $con)->diff($featureAvI18ns); - $this->featureAvI18nsScheduledForDeletion = unserialize(serialize($featureAvI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->featureAvI18nsScheduledForDeletion = clone $featureAvI18nsToDelete; foreach ($featureAvI18nsToDelete as $featureAvI18nRemoved) { $featureAvI18nRemoved->setFeatureAv(null); @@ -1611,13 +1717,13 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Returns the number of related FeatureAvI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FeatureAvI18n objects. * @throws PropelException */ - public function countFeatureAvI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFeatureAvI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureAvI18nsPartial && !$this->isNew(); if (null === $this->collFeatureAvI18ns || null !== $criteria || $partial) { @@ -1625,10 +1731,11 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getFeatureAvI18ns()); } - $query = FeatureAvI18nQuery::create(null, $criteria); + + $query = ChildFeatureAvI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1642,13 +1749,13 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } /** - * Method called to associate a FeatureAvI18n object to this object - * through the FeatureAvI18n foreign key attribute. + * Method called to associate a ChildFeatureAvI18n object to this object + * through the ChildFeatureAvI18n foreign key attribute. * - * @param FeatureAvI18n $l FeatureAvI18n - * @return FeatureAv The current object (for fluent API support) + * @param ChildFeatureAvI18n $l ChildFeatureAvI18n + * @return \Thelia\Model\FeatureAv The current object (for fluent API support) */ - public function addFeatureAvI18n(FeatureAvI18n $l) + public function addFeatureAvI18n(ChildFeatureAvI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1658,6 +1765,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $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); } @@ -1666,7 +1774,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } /** - * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to add. + * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to add. */ protected function doAddFeatureAvI18n($featureAvI18n) { @@ -1675,8 +1783,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } /** - * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to remove. - * @return FeatureAv The current object (for fluent API support) + * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to remove. + * @return ChildFeatureAv The current object (for fluent API support) */ public function removeFeatureAvI18n($featureAvI18n) { @@ -1703,8 +1811,6 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1716,14 +1822,13 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collFeatureProds) { foreach ($this->collFeatureProds as $o) { $o->clearAllReferences($deep); @@ -1734,22 +1839,17 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->aFeature instanceof Persistent) { - $this->aFeature->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collFeatureProds instanceof PropelCollection) { + if ($this->collFeatureProds instanceof Collection) { $this->collFeatureProds->clearIterator(); } $this->collFeatureProds = null; - if ($this->collFeatureAvI18ns instanceof PropelCollection) { + if ($this->collFeatureAvI18ns instanceof Collection) { $this->collFeatureAvI18ns->clearIterator(); } $this->collFeatureAvI18ns = null; @@ -1757,23 +1857,13 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(FeatureAvTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1781,11 +1871,11 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * 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) + * @return ChildFeatureAv The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = FeatureAvPeer::UPDATED_AT; + $this->modifiedColumns[] = FeatureAvTableMap::UPDATED_AT; return $this; } @@ -1797,9 +1887,9 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return FeatureAv The current object (for fluent API support) + * @return ChildFeatureAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1820,10 +1910,10 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return FeatureAvI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildFeatureAvI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureAvI18ns) { @@ -1836,10 +1926,10 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new FeatureAvI18n(); + $translation = new ChildFeatureAvI18n(); $translation->setLocale($locale); } else { - $translation = FeatureAvI18nQuery::create() + $translation = ChildFeatureAvI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -1854,14 +1944,14 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return FeatureAv The current object (for fluent API support) + * @return ChildFeatureAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - FeatureAvI18nQuery::create() + ChildFeatureAvI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -1881,10 +1971,10 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return FeatureAvI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildFeatureAvI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -1893,7 +1983,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -1904,8 +1994,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -1917,7 +2007,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -1928,8 +2018,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -1941,7 +2031,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -1952,8 +2042,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -1965,7 +2055,7 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -1976,8 +2066,8 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -1985,4 +2075,122 @@ abstract class BaseFeatureAv extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18n.php b/core/lib/Thelia/Model/Base/FeatureAvI18n.php new file mode 100644 index 000000000..aa524c430 --- /dev/null +++ b/core/lib/Thelia/Model/Base/FeatureAvI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\FeatureAvI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FeatureAvI18n instance. If + * obj is an instance of FeatureAvI18n, delegates to + * equals(FeatureAvI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FeatureAvI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FeatureAvI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\FeatureAvI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = FeatureAvI18nTableMap::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 \Thelia\Model\FeatureAvI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = FeatureAvI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = FeatureAvI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = FeatureAvI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = FeatureAvI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = FeatureAvI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureAvI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureAvI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureAvI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureAvI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureAvI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureAvI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = FeatureAvI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\FeatureAvI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(FeatureAvI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildFeatureAvI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aFeatureAv = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see FeatureAvI18n::setDeleted() + * @see FeatureAvI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildFeatureAvI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME); + } + + $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); + FeatureAvI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(FeatureAvI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(FeatureAvI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(FeatureAvI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(FeatureAvI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(FeatureAvI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(FeatureAvI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = FeatureAvI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['FeatureAvI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['FeatureAvI18n'][serialize($this->getPrimaryKey())] = true; + $keys = FeatureAvI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = FeatureAvI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = FeatureAvI18nTableMap::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(FeatureAvI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(FeatureAvI18nTableMap::ID)) $criteria->add(FeatureAvI18nTableMap::ID, $this->id); + if ($this->isColumnModified(FeatureAvI18nTableMap::LOCALE)) $criteria->add(FeatureAvI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(FeatureAvI18nTableMap::TITLE)) $criteria->add(FeatureAvI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(FeatureAvI18nTableMap::DESCRIPTION)) $criteria->add(FeatureAvI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(FeatureAvI18nTableMap::CHAPO)) $criteria->add(FeatureAvI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(FeatureAvI18nTableMap::POSTSCRIPTUM)) $criteria->add(FeatureAvI18nTableMap::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(FeatureAvI18nTableMap::DATABASE_NAME); + $criteria->add(FeatureAvI18nTableMap::ID, $this->id); + $criteria->add(FeatureAvI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildFeatureAv object. + * + * @param ChildFeatureAv $v + * @return \Thelia\Model\FeatureAvI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setFeatureAv(ChildFeatureAv $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 ChildFeatureAv object, it will not be re-added. + if ($v !== null) { + $v->addFeatureAvI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildFeatureAv object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFeatureAv The associated ChildFeatureAv object. + * @throws PropelException + */ + public function getFeatureAv(ConnectionInterface $con = null) + { + if ($this->aFeatureAv === null && ($this->id !== null)) { + $this->aFeatureAv = ChildFeatureAvQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aFeatureAv = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(FeatureAvI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php b/core/lib/Thelia/Model/Base/FeatureAvI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php rename to core/lib/Thelia/Model/Base/FeatureAvI18nQuery.php index f305575dc..bab9fd843 --- a/core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureAvI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return FeatureAvI18n|FeatureAvI18n[]|mixed the result, formatted by the current formatter + * @return ChildFeatureAvI18n|array|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 + if ((null !== ($obj = FeatureAvI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(FeatureAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FeatureAvI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return FeatureAvI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildFeatureAvI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `feature_av_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FeatureAvI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFeatureAvI18n(); $obj->hydrate($row); - FeatureAvI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + FeatureAvI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return FeatureAvI18n|FeatureAvI18n[]|mixed the result, formatted by the current formatter + * @return ChildFeatureAvI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|FeatureAvI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return FeatureAvI18nQuery The current query, for fluid interface + * @return ChildFeatureAvI18nQuery 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); + $this->addUsingAlias(FeatureAvI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(FeatureAvI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return FeatureAvI18nQuery The current query, for fluid interface + * @return ChildFeatureAvI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(FeatureAvI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(FeatureAvI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByFeatureAv() @@ -270,18 +266,18 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureAvI18nQuery 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); + $this->addUsingAlias(FeatureAvI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FeatureAvI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureAvI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(FeatureAvI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureAvI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(FeatureAvI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureAvI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(FeatureAvI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureAvI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(FeatureAvI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureAvI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(FeatureAvI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureAvI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(FeatureAvI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related FeatureAv object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureAv|ObjectCollection $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. + * @return ChildFeatureAvI18nQuery The current query, for fluid interface */ public function filterByFeatureAv($featureAv, $comparison = null) { - if ($featureAv instanceof FeatureAv) { + if ($featureAv instanceof \Thelia\Model\FeatureAv) { return $this - ->addUsingAlias(FeatureAvI18nPeer::ID, $featureAv->getId(), $comparison); - } elseif ($featureAv instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureAvI18nTableMap::ID, $featureAv->getId(), $comparison); + } elseif ($featureAv instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureAvI18nPeer::ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureAvI18nTableMap::ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); + throw new PropelException('filterByFeatureAv() only accepts arguments of type \Thelia\Model\FeatureAv or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria * @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 + * @return ChildFeatureAvI18nQuery The current query, for fluid interface */ public function joinFeatureAv($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria /** * Use the FeatureAv relation FeatureAv object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseFeatureAvI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param FeatureAvI18n $featureAvI18n Object to remove from the list of results + * @param ChildFeatureAvI18n $featureAvI18n Object to remove from the list of results * - * @return FeatureAvI18nQuery The current query, for fluid interface + * @return ChildFeatureAvI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(FeatureAvI18nTableMap::ID), $featureAvI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(FeatureAvI18nTableMap::LOCALE), $featureAvI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the feature_av_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FeatureAvI18nTableMap::clearInstancePool(); + FeatureAvI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFeatureAvI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFeatureAvI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FeatureAvI18nTableMap::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(); + + + FeatureAvI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FeatureAvI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // FeatureAvI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php b/core/lib/Thelia/Model/Base/FeatureAvQuery.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseFeatureAvQuery.php rename to core/lib/Thelia/Model/Base/FeatureAvQuery.php index 98f1fd0e4..abdb2f497 --- a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureAvQuery.php @@ -1,97 +1,96 @@ setModelAlias($modelAlias); } @@ -112,21 +111,21 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return FeatureAv|FeatureAv[]|mixed the result, formatted by the current formatter + * @return ChildFeatureAv|array|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 + if ((null !== ($obj = FeatureAvTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FeatureAvTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -138,46 +137,31 @@ abstract class BaseFeatureAvQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return FeatureAv A model object, or null if the key is not found - * @throws PropelException + * @return ChildFeatureAv A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `feature_id`, `created_at`, `updated_at` FROM `feature_av` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FeatureAv(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFeatureAv(); $obj->hydrate($row); - FeatureAvPeer::addInstanceToPool($obj, (string) $key); + FeatureAvTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -188,19 +172,19 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return FeatureAv|FeatureAv[]|mixed the result, formatted by the current formatter + * @return ChildFeatureAv|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -209,22 +193,22 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|FeatureAv[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -232,12 +216,12 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return FeatureAvQuery The current query, for fluid interface + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(FeatureAvPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(FeatureAvTableMap::ID, $key, Criteria::EQUAL); } /** @@ -245,12 +229,12 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return FeatureAvQuery The current query, for fluid interface + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(FeatureAvPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(FeatureAvTableMap::ID, $keys, Criteria::IN); } /** @@ -260,8 +244,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -270,18 +253,18 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * 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 + * @return ChildFeatureAvQuery 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); + $this->addUsingAlias(FeatureAvTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FeatureAvPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureAvTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +275,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvPeer::ID, $id, $comparison); + return $this->addUsingAlias(FeatureAvTableMap::ID, $id, $comparison); } /** @@ -302,8 +285,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * $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 + * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12 * * * @see filterByFeature() @@ -314,18 +296,18 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * 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 + * @return ChildFeatureAvQuery 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); + $this->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($featureId['max'])) { - $this->addUsingAlias(FeatureAvPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -336,7 +318,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvPeer::FEATURE_ID, $featureId, $comparison); + return $this->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $featureId, $comparison); } /** @@ -357,18 +339,18 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * 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 + * @return ChildFeatureAvQuery 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); + $this->addUsingAlias(FeatureAvTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(FeatureAvPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureAvTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -379,7 +361,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(FeatureAvTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -400,18 +382,18 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * 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 + * @return ChildFeatureAvQuery 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); + $this->addUsingAlias(FeatureAvTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureAvTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -422,32 +404,31 @@ abstract class BaseFeatureAvQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(FeatureAvTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Feature object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Feature|ObjectCollection $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. + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function filterByFeature($feature, $comparison = null) { - if ($feature instanceof Feature) { + if ($feature instanceof \Thelia\Model\Feature) { return $this - ->addUsingAlias(FeatureAvPeer::FEATURE_ID, $feature->getId(), $comparison); - } elseif ($feature instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $feature->getId(), $comparison); + } elseif ($feature instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureAvPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureAvTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection'); + throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection'); } } @@ -457,7 +438,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @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 + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -486,7 +467,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria /** * Use the Feature relation Feature object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -502,26 +483,25 @@ abstract class BaseFeatureAvQuery extends ModelCriteria } /** - * Filter the query by a related FeatureProd object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureProd|ObjectCollection $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. + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function filterByFeatureProd($featureProd, $comparison = null) { - if ($featureProd instanceof FeatureProd) { + if ($featureProd instanceof \Thelia\Model\FeatureProd) { return $this - ->addUsingAlias(FeatureAvPeer::ID, $featureProd->getFeatureAvId(), $comparison); - } elseif ($featureProd instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureAvTableMap::ID, $featureProd->getFeatureAvId(), $comparison); + } elseif ($featureProd instanceof ObjectCollection) { return $this ->useFeatureProdQuery() ->filterByPrimaryKeys($featureProd->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection'); + throw new PropelException('filterByFeatureProd() only accepts arguments of type \Thelia\Model\FeatureProd or Collection'); } } @@ -531,7 +511,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @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 + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -560,7 +540,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria /** * Use the FeatureProd relation FeatureProd object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -576,26 +556,25 @@ abstract class BaseFeatureAvQuery extends ModelCriteria } /** - * Filter the query by a related FeatureAvI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureAvI18n|ObjectCollection $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. + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function filterByFeatureAvI18n($featureAvI18n, $comparison = null) { - if ($featureAvI18n instanceof FeatureAvI18n) { + if ($featureAvI18n instanceof \Thelia\Model\FeatureAvI18n) { return $this - ->addUsingAlias(FeatureAvPeer::ID, $featureAvI18n->getId(), $comparison); - } elseif ($featureAvI18n instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureAvTableMap::ID, $featureAvI18n->getId(), $comparison); + } elseif ($featureAvI18n instanceof ObjectCollection) { return $this ->useFeatureAvI18nQuery() ->filterByPrimaryKeys($featureAvI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFeatureAvI18n() only accepts arguments of type FeatureAvI18n or PropelCollection'); + throw new PropelException('filterByFeatureAvI18n() only accepts arguments of type \Thelia\Model\FeatureAvI18n or Collection'); } } @@ -605,7 +584,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @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 + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function joinFeatureAvI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -634,7 +613,7 @@ abstract class BaseFeatureAvQuery extends ModelCriteria /** * Use the FeatureAvI18n relation FeatureAvI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -652,19 +631,94 @@ abstract class BaseFeatureAvQuery extends ModelCriteria /** * Exclude object from result * - * @param FeatureAv $featureAv Object to remove from the list of results + * @param ChildFeatureAv $featureAv Object to remove from the list of results * - * @return FeatureAvQuery The current query, for fluid interface + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function prune($featureAv = null) { if ($featureAv) { - $this->addUsingAlias(FeatureAvPeer::ID, $featureAv->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(FeatureAvTableMap::ID, $featureAv->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the feature_av table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FeatureAvTableMap::clearInstancePool(); + FeatureAvTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFeatureAv or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFeatureAv object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FeatureAvTableMap::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(); + + + FeatureAvTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FeatureAvTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -672,31 +726,11 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return FeatureAvQuery The current query, for fluid interface + * @return ChildFeatureAvQuery 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); + return $this->addUsingAlias(FeatureAvTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -704,32 +738,53 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return FeatureAvQuery The current query, for fluid interface + * @return ChildFeatureAvQuery 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); + return $this->addUsingAlias(FeatureAvTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildFeatureAvQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureAvTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildFeatureAvQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureAvTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return FeatureAvQuery The current query, for fluid interface + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(FeatureAvPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(FeatureAvTableMap::CREATED_AT); } /** * Order by create date asc * - * @return FeatureAvQuery The current query, for fluid interface + * @return ChildFeatureAvQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(FeatureAvPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(FeatureAvTableMap::CREATED_AT); } + // i18n behavior /** @@ -739,9 +794,9 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @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 + * @return ChildFeatureAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureAvI18n'; @@ -757,9 +812,9 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @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 + * @return ChildFeatureAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -778,13 +833,13 @@ abstract class BaseFeatureAvQuery extends ModelCriteria * @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 + * @return ChildFeatureAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureAvI18n', 'Thelia\Model\FeatureAvI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'FeatureAvI18n', '\Thelia\Model\FeatureAvI18nQuery'); } -} +} // FeatureAvQuery diff --git a/core/lib/Thelia/Model/Base/FeatureCategory.php b/core/lib/Thelia/Model/Base/FeatureCategory.php new file mode 100644 index 000000000..f3ce14349 --- /dev/null +++ b/core/lib/Thelia/Model/Base/FeatureCategory.php @@ -0,0 +1,1495 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FeatureCategory instance. If + * obj is an instance of FeatureCategory, delegates to + * equals(FeatureCategory). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FeatureCategory The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FeatureCategory The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = FeatureCategoryTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [feature_id] column. + * + * @param int $v new value + * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + */ + public function setFeatureId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->feature_id !== $v) { + $this->feature_id = $v; + $this->modifiedColumns[] = FeatureCategoryTableMap::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 \Thelia\Model\FeatureCategory The current object (for fluent API support) + */ + public function setCategoryId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->category_id !== $v) { + $this->category_id = $v; + $this->modifiedColumns[] = FeatureCategoryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = FeatureCategoryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = FeatureCategoryTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureCategoryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureCategoryTableMap::translateFieldName('FeatureId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->feature_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = FeatureCategoryTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\FeatureCategory object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(FeatureCategoryTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildFeatureCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see FeatureCategory::setDeleted() + * @see FeatureCategory::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildFeatureCategoryQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + FeatureCategoryTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = FeatureCategoryTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureCategoryTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(FeatureCategoryTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(FeatureCategoryTableMap::FEATURE_ID)) { + $modifiedColumns[':p' . $index++] = 'FEATURE_ID'; + } + if ($this->isColumnModified(FeatureCategoryTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; + } + if ($this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(FeatureCategoryTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = FeatureCategoryTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()] = true; + $keys = FeatureCategoryTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getFeatureId(), + $keys[2] => $this->getCategoryId(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = FeatureCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = FeatureCategoryTableMap::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(FeatureCategoryTableMap::DATABASE_NAME); + + if ($this->isColumnModified(FeatureCategoryTableMap::ID)) $criteria->add(FeatureCategoryTableMap::ID, $this->id); + if ($this->isColumnModified(FeatureCategoryTableMap::FEATURE_ID)) $criteria->add(FeatureCategoryTableMap::FEATURE_ID, $this->feature_id); + if ($this->isColumnModified(FeatureCategoryTableMap::CATEGORY_ID)) $criteria->add(FeatureCategoryTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(FeatureCategoryTableMap::CREATED_AT)) $criteria->add(FeatureCategoryTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FeatureCategoryTableMap::UPDATED_AT)) $criteria->add(FeatureCategoryTableMap::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(FeatureCategoryTableMap::DATABASE_NAME); + $criteria->add(FeatureCategoryTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $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 ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addFeatureCategory($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::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->addFeatureCategories($this); + */ + } + + return $this->aCategory; + } + + /** + * Declares an association between this object and a ChildFeature object. + * + * @param ChildFeature $v + * @return \Thelia\Model\FeatureCategory The current object (for fluent API support) + * @throws PropelException + */ + public function setFeature(ChildFeature $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 ChildFeature object, it will not be re-added. + if ($v !== null) { + $v->addFeatureCategory($this); + } + + + return $this; + } + + + /** + * Get the associated ChildFeature object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFeature The associated ChildFeature object. + * @throws PropelException + */ + public function getFeature(ConnectionInterface $con = null) + { + if ($this->aFeature === null && ($this->feature_id !== null)) { + $this->aFeature = ChildFeatureQuery::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->addFeatureCategories($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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCategory = null; + $this->aFeature = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(FeatureCategoryTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildFeatureCategory The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = FeatureCategoryTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php b/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php rename to core/lib/Thelia/Model/Base/FeatureCategoryQuery.php index f0481ff21..b9c9a67be --- a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureCategoryQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -111,21 +110,21 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return FeatureCategory|FeatureCategory[]|mixed the result, formatted by the current formatter + * @return ChildFeatureCategory|array|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 + if ((null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FeatureCategoryTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -137,46 +136,31 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return FeatureCategory A model object, or null if the key is not found - * @throws PropelException + * @return ChildFeatureCategory A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `feature_id`, `category_id`, `created_at`, `updated_at` FROM `feature_category` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FeatureCategory(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFeatureCategory(); $obj->hydrate($row); - FeatureCategoryPeer::addInstanceToPool($obj, (string) $key); + FeatureCategoryTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -187,19 +171,19 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return FeatureCategory|FeatureCategory[]|mixed the result, formatted by the current formatter + * @return ChildFeatureCategory|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -208,22 +192,22 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|FeatureCategory[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -231,12 +215,12 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return FeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureCategoryQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(FeatureCategoryPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(FeatureCategoryTableMap::ID, $key, Criteria::EQUAL); } /** @@ -244,12 +228,12 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return FeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureCategoryQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(FeatureCategoryPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(FeatureCategoryTableMap::ID, $keys, Criteria::IN); } /** @@ -259,8 +243,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -269,18 +252,18 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * 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 + * @return ChildFeatureCategoryQuery 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); + $this->addUsingAlias(FeatureCategoryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureCategoryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -291,7 +274,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryPeer::ID, $id, $comparison); + return $this->addUsingAlias(FeatureCategoryTableMap::ID, $id, $comparison); } /** @@ -301,8 +284,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * $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 + * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12 * * * @see filterByFeature() @@ -313,18 +295,18 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * 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 + * @return ChildFeatureCategoryQuery 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); + $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($featureId['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -335,7 +317,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $featureId, $comparison); + return $this->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $featureId, $comparison); } /** @@ -345,8 +327,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * $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 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 * * * @see filterByCategory() @@ -357,18 +338,18 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * 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 + * @return ChildFeatureCategoryQuery 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); + $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($categoryId['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -379,7 +360,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $categoryId, $comparison); } /** @@ -400,18 +381,18 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * 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 + * @return ChildFeatureCategoryQuery 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); + $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -422,7 +403,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -443,18 +424,18 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * 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 + * @return ChildFeatureCategoryQuery 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); + $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -465,32 +446,31 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Category object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Category|ObjectCollection $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. + * @return ChildFeatureCategoryQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = null) { - if ($category instanceof Category) { + if ($category instanceof \Thelia\Model\Category) { return $this - ->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); } } @@ -500,7 +480,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * @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 + * @return ChildFeatureCategoryQuery The current query, for fluid interface */ public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -529,7 +509,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria /** * Use the Category relation Category object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -545,28 +525,27 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria } /** - * Filter the query by a related Feature object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Feature|ObjectCollection $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. + * @return ChildFeatureCategoryQuery The current query, for fluid interface */ public function filterByFeature($feature, $comparison = null) { - if ($feature instanceof Feature) { + if ($feature instanceof \Thelia\Model\Feature) { return $this - ->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $feature->getId(), $comparison); - } elseif ($feature instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->getId(), $comparison); + } elseif ($feature instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureCategoryTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection'); + throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection'); } } @@ -576,7 +555,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * @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 + * @return ChildFeatureCategoryQuery The current query, for fluid interface */ public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -605,7 +584,7 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria /** * Use the Feature relation Feature object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -623,19 +602,94 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria /** * Exclude object from result * - * @param FeatureCategory $featureCategory Object to remove from the list of results + * @param ChildFeatureCategory $featureCategory Object to remove from the list of results * - * @return FeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureCategoryQuery The current query, for fluid interface */ public function prune($featureCategory = null) { if ($featureCategory) { - $this->addUsingAlias(FeatureCategoryPeer::ID, $featureCategory->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(FeatureCategoryTableMap::ID, $featureCategory->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the feature_category table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FeatureCategoryTableMap::clearInstancePool(); + FeatureCategoryTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFeatureCategory or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFeatureCategory object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FeatureCategoryTableMap::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(); + + + FeatureCategoryTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FeatureCategoryTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -643,31 +697,11 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return FeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureCategoryQuery 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); + return $this->addUsingAlias(FeatureCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -675,30 +709,51 @@ abstract class BaseFeatureCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return FeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureCategoryQuery 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); + return $this->addUsingAlias(FeatureCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildFeatureCategoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildFeatureCategoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return FeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureCategoryQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(FeatureCategoryPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT); } /** * Order by create date asc * - * @return FeatureCategoryQuery The current query, for fluid interface + * @return ChildFeatureCategoryQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(FeatureCategoryPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(FeatureCategoryTableMap::CREATED_AT); } -} + +} // FeatureCategoryQuery diff --git a/core/lib/Thelia/Model/Base/FeatureI18n.php b/core/lib/Thelia/Model/Base/FeatureI18n.php new file mode 100644 index 000000000..b6070932e --- /dev/null +++ b/core/lib/Thelia/Model/Base/FeatureI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\FeatureI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FeatureI18n instance. If + * obj is an instance of FeatureI18n, delegates to + * equals(FeatureI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FeatureI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FeatureI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\FeatureI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = FeatureI18nTableMap::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 \Thelia\Model\FeatureI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = FeatureI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\FeatureI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = FeatureI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\FeatureI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = FeatureI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\FeatureI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = FeatureI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\FeatureI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = FeatureI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = FeatureI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\FeatureI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(FeatureI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildFeatureI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aFeature = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see FeatureI18n::setDeleted() + * @see FeatureI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildFeatureI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME); + } + + $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); + FeatureI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(FeatureI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(FeatureI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(FeatureI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(FeatureI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(FeatureI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(FeatureI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = FeatureI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['FeatureI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['FeatureI18n'][serialize($this->getPrimaryKey())] = true; + $keys = FeatureI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = FeatureI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = FeatureI18nTableMap::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(FeatureI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(FeatureI18nTableMap::ID)) $criteria->add(FeatureI18nTableMap::ID, $this->id); + if ($this->isColumnModified(FeatureI18nTableMap::LOCALE)) $criteria->add(FeatureI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(FeatureI18nTableMap::TITLE)) $criteria->add(FeatureI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(FeatureI18nTableMap::DESCRIPTION)) $criteria->add(FeatureI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(FeatureI18nTableMap::CHAPO)) $criteria->add(FeatureI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(FeatureI18nTableMap::POSTSCRIPTUM)) $criteria->add(FeatureI18nTableMap::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(FeatureI18nTableMap::DATABASE_NAME); + $criteria->add(FeatureI18nTableMap::ID, $this->id); + $criteria->add(FeatureI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildFeature object. + * + * @param ChildFeature $v + * @return \Thelia\Model\FeatureI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setFeature(ChildFeature $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 ChildFeature object, it will not be re-added. + if ($v !== null) { + $v->addFeatureI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildFeature object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFeature The associated ChildFeature object. + * @throws PropelException + */ + public function getFeature(ConnectionInterface $con = null) + { + if ($this->aFeature === null && ($this->id !== null)) { + $this->aFeature = ChildFeatureQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aFeature = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(FeatureI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php b/core/lib/Thelia/Model/Base/FeatureI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php rename to core/lib/Thelia/Model/Base/FeatureI18nQuery.php index d07e8d108..5f7080be6 --- a/core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return FeatureI18n|FeatureI18n[]|mixed the result, formatted by the current formatter + * @return ChildFeatureI18n|array|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 + if ((null !== ($obj = FeatureI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(FeatureI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FeatureI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return FeatureI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildFeatureI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `feature_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FeatureI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFeatureI18n(); $obj->hydrate($row); - FeatureI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + FeatureI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return FeatureI18n|FeatureI18n[]|mixed the result, formatted by the current formatter + * @return ChildFeatureI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|FeatureI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return FeatureI18nQuery The current query, for fluid interface + * @return ChildFeatureI18nQuery 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); + $this->addUsingAlias(FeatureI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(FeatureI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return FeatureI18nQuery The current query, for fluid interface + * @return ChildFeatureI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(FeatureI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(FeatureI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByFeature() @@ -270,18 +266,18 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureI18nQuery 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); + $this->addUsingAlias(FeatureI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FeatureI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(FeatureI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(FeatureI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(FeatureI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(FeatureI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(FeatureI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * 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 + * @return ChildFeatureI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(FeatureI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Feature object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Feature|ObjectCollection $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. + * @return ChildFeatureI18nQuery The current query, for fluid interface */ public function filterByFeature($feature, $comparison = null) { - if ($feature instanceof Feature) { + if ($feature instanceof \Thelia\Model\Feature) { return $this - ->addUsingAlias(FeatureI18nPeer::ID, $feature->getId(), $comparison); - } elseif ($feature instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureI18nTableMap::ID, $feature->getId(), $comparison); + } elseif ($feature instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureI18nPeer::ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureI18nTableMap::ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection'); + throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria * @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 + * @return ChildFeatureI18nQuery The current query, for fluid interface */ public function joinFeature($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria /** * Use the Feature relation Feature object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseFeatureI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param FeatureI18n $featureI18n Object to remove from the list of results + * @param ChildFeatureI18n $featureI18n Object to remove from the list of results * - * @return FeatureI18nQuery The current query, for fluid interface + * @return ChildFeatureI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(FeatureI18nTableMap::ID), $featureI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(FeatureI18nTableMap::LOCALE), $featureI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the feature_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FeatureI18nTableMap::clearInstancePool(); + FeatureI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFeatureI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFeatureI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FeatureI18nTableMap::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(); + + + FeatureI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FeatureI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // FeatureI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseFeatureProd.php b/core/lib/Thelia/Model/Base/FeatureProd.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseFeatureProd.php rename to core/lib/Thelia/Model/Base/FeatureProd.php index 68d6f9ce0..0f14fae8e --- a/core/lib/Thelia/Model/om/BaseFeatureProd.php +++ b/core/lib/Thelia/Model/Base/FeatureProd.php @@ -1,55 +1,64 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FeatureProd instance. If + * obj is an instance of FeatureProd, delegates to + * equals(FeatureProd). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FeatureProd The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FeatureProd The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [product_id] column value. * - * @return int + * @return int */ public function getProductId() { + return $this->product_id; } /** * Get the [feature_id] column value. * - * @return int + * @return int */ public function getFeatureId() { + return $this->feature_id; } /** * Get the [feature_av_id] column value. * - * @return int + * @return int */ public function getFeatureAvId() { + return $this->feature_av_id; } /** * Get the [by_default] column value. * - * @return string + * @return string */ public function getByDefault() { + return $this->by_default; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -198,97 +455,57 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = FeatureProdPeer::ID; + $this->modifiedColumns[] = FeatureProdTableMap::ID; } @@ -298,18 +515,18 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * Set the value of [product_id] column. * - * @param int $v new value - * @return FeatureProd The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) */ public function setProductId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->product_id !== $v) { $this->product_id = $v; - $this->modifiedColumns[] = FeatureProdPeer::PRODUCT_ID; + $this->modifiedColumns[] = FeatureProdTableMap::PRODUCT_ID; } if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { @@ -323,18 +540,18 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * Set the value of [feature_id] column. * - * @param int $v new value - * @return FeatureProd The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) */ public function setFeatureId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->feature_id !== $v) { $this->feature_id = $v; - $this->modifiedColumns[] = FeatureProdPeer::FEATURE_ID; + $this->modifiedColumns[] = FeatureProdTableMap::FEATURE_ID; } if ($this->aFeature !== null && $this->aFeature->getId() !== $v) { @@ -348,18 +565,18 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * Set the value of [feature_av_id] column. * - * @param int $v new value - * @return FeatureProd The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) */ public function setFeatureAvId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->feature_av_id !== $v) { $this->feature_av_id = $v; - $this->modifiedColumns[] = FeatureProdPeer::FEATURE_AV_ID; + $this->modifiedColumns[] = FeatureProdTableMap::FEATURE_AV_ID; } if ($this->aFeatureAv !== null && $this->aFeatureAv->getId() !== $v) { @@ -373,18 +590,18 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * Set the value of [by_default] column. * - * @param string $v new value - * @return FeatureProd The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) */ public function setByDefault($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->by_default !== $v) { $this->by_default = $v; - $this->modifiedColumns[] = FeatureProdPeer::BY_DEFAULT; + $this->modifiedColumns[] = FeatureProdTableMap::BY_DEFAULT; } @@ -394,18 +611,18 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return FeatureProd The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = FeatureProdPeer::POSITION; + $this->modifiedColumns[] = FeatureProdTableMap::POSITION; } @@ -415,19 +632,17 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = FeatureProdTableMap::CREATED_AT; } } // if either are not null @@ -438,19 +653,17 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = FeatureProdTableMap::UPDATED_AT; } } // if either are not null @@ -468,7 +681,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -480,24 +693,50 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FeatureProdTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureProdTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureProdTableMap::translateFieldName('FeatureId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->feature_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureProdTableMap::translateFieldName('FeatureAvId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->feature_av_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureProdTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->by_default = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureProdTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : FeatureProdTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FeatureProdTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -505,11 +744,11 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = FeatureProdPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 8; // 8 = FeatureProdTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating FeatureProd object", $e); + throw new PropelException("Error populating \Thelia\Model\FeatureProd object", 0, $e); } } @@ -528,7 +767,6 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { $this->aProduct = null; } @@ -545,12 +783,12 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -561,19 +799,19 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FeatureProdTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildFeatureProdQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -586,26 +824,25 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see FeatureProd::setDeleted() + * @see FeatureProd::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = FeatureProdQuery::create() + $deleteQuery = ChildFeatureProdQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -630,20 +867,19 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -653,16 +889,16 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(FeatureProdPeer::CREATED_AT)) { + if (!$this->isColumnModified(FeatureProdTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(FeatureProdPeer::UPDATED_AT)) { + if (!$this->isColumnModified(FeatureProdTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FeatureProdPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(FeatureProdTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -674,7 +910,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - FeatureProdPeer::addInstanceToPool($this); + FeatureProdTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -693,19 +929,19 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -751,49 +987,49 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = FeatureProdPeer::ID; + $this->modifiedColumns[] = FeatureProdTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureProdPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureProdTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeatureProdPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(FeatureProdTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(FeatureProdPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; + if ($this->isColumnModified(FeatureProdTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; } - if ($this->isColumnModified(FeatureProdPeer::FEATURE_ID)) { - $modifiedColumns[':p' . $index++] = '`feature_id`'; + if ($this->isColumnModified(FeatureProdTableMap::FEATURE_ID)) { + $modifiedColumns[':p' . $index++] = 'FEATURE_ID'; } - if ($this->isColumnModified(FeatureProdPeer::FEATURE_AV_ID)) { - $modifiedColumns[':p' . $index++] = '`feature_av_id`'; + if ($this->isColumnModified(FeatureProdTableMap::FEATURE_AV_ID)) { + $modifiedColumns[':p' . $index++] = 'FEATURE_AV_ID'; } - if ($this->isColumnModified(FeatureProdPeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`by_default`'; + if ($this->isColumnModified(FeatureProdTableMap::BY_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'BY_DEFAULT'; } - if ($this->isColumnModified(FeatureProdPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(FeatureProdTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(FeatureProdPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(FeatureProdTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(FeatureProdPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(FeatureProdTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `feature_prod` (%s) VALUES (%s)', + 'INSERT INTO feature_prod (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -802,42 +1038,42 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`product_id`': + case 'PRODUCT_ID': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`feature_id`': + case 'FEATURE_ID': $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT); break; - case '`feature_av_id`': + case 'FEATURE_AV_ID': $stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT); break; - case '`by_default`': + case 'BY_DEFAULT': $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_STR); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -847,128 +1083,32 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = FeatureProdPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = FeatureProdTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -978,7 +1118,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1020,22 +1160,22 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = FeatureProdTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getProductId(), @@ -1046,6 +1186,12 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $keys[6] => $this->getCreatedAt(), $keys[7] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aProduct) { $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -1064,27 +1210,27 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = FeatureProdPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = FeatureProdTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1126,17 +1272,17 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = FeatureProdPeer::getFieldNames($keyType); + $keys = FeatureProdTableMap::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]]); @@ -1155,16 +1301,16 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME); + $criteria = new Criteria(FeatureProdTableMap::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); + if ($this->isColumnModified(FeatureProdTableMap::ID)) $criteria->add(FeatureProdTableMap::ID, $this->id); + if ($this->isColumnModified(FeatureProdTableMap::PRODUCT_ID)) $criteria->add(FeatureProdTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(FeatureProdTableMap::FEATURE_ID)) $criteria->add(FeatureProdTableMap::FEATURE_ID, $this->feature_id); + if ($this->isColumnModified(FeatureProdTableMap::FEATURE_AV_ID)) $criteria->add(FeatureProdTableMap::FEATURE_AV_ID, $this->feature_av_id); + if ($this->isColumnModified(FeatureProdTableMap::BY_DEFAULT)) $criteria->add(FeatureProdTableMap::BY_DEFAULT, $this->by_default); + if ($this->isColumnModified(FeatureProdTableMap::POSITION)) $criteria->add(FeatureProdTableMap::POSITION, $this->position); + if ($this->isColumnModified(FeatureProdTableMap::CREATED_AT)) $criteria->add(FeatureProdTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FeatureProdTableMap::UPDATED_AT)) $criteria->add(FeatureProdTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1179,15 +1325,15 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME); - $criteria->add(FeatureProdPeer::ID, $this->id); + $criteria = new Criteria(FeatureProdTableMap::DATABASE_NAME); + $criteria->add(FeatureProdTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1197,7 +1343,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1221,9 +1367,9 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1235,18 +1381,6 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $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 @@ -1261,8 +1395,8 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\FeatureProd Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1276,31 +1410,13 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildProduct object. * - * 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) + * @param ChildProduct $v + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) * @throws PropelException */ - public function setProduct(Product $v = null) + public function setProduct(ChildProduct $v = null) { if ($v === null) { $this->setProductId(NULL); @@ -1311,7 +1427,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $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 this object has already been added to the ChildProduct object, it will not be re-added. if ($v !== null) { $v->addFeatureProd($this); } @@ -1322,17 +1438,16 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** - * Get the associated Product object + * Get the associated ChildProduct object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null, $doQuery = true) + public function getProduct(ConnectionInterface $con = null) { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::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 @@ -1346,13 +1461,13 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } /** - * Declares an association between this object and a Feature object. + * Declares an association between this object and a ChildFeature object. * - * @param Feature $v - * @return FeatureProd The current object (for fluent API support) + * @param ChildFeature $v + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) * @throws PropelException */ - public function setFeature(Feature $v = null) + public function setFeature(ChildFeature $v = null) { if ($v === null) { $this->setFeatureId(NULL); @@ -1363,7 +1478,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $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 this object has already been added to the ChildFeature object, it will not be re-added. if ($v !== null) { $v->addFeatureProd($this); } @@ -1374,17 +1489,16 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** - * Get the associated Feature object + * Get the associated ChildFeature object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Feature The associated Feature object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFeature The associated ChildFeature object. * @throws PropelException */ - public function getFeature(PropelPDO $con = null, $doQuery = true) + public function getFeature(ConnectionInterface $con = null) { - if ($this->aFeature === null && ($this->feature_id !== null) && $doQuery) { - $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con); + if ($this->aFeature === null && ($this->feature_id !== null)) { + $this->aFeature = ChildFeatureQuery::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 @@ -1398,13 +1512,13 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } /** - * Declares an association between this object and a FeatureAv object. + * Declares an association between this object and a ChildFeatureAv object. * - * @param FeatureAv $v - * @return FeatureProd The current object (for fluent API support) + * @param ChildFeatureAv $v + * @return \Thelia\Model\FeatureProd The current object (for fluent API support) * @throws PropelException */ - public function setFeatureAv(FeatureAv $v = null) + public function setFeatureAv(ChildFeatureAv $v = null) { if ($v === null) { $this->setFeatureAvId(NULL); @@ -1415,7 +1529,7 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $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 this object has already been added to the ChildFeatureAv object, it will not be re-added. if ($v !== null) { $v->addFeatureProd($this); } @@ -1426,17 +1540,16 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** - * Get the associated FeatureAv object + * Get the associated ChildFeatureAv object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return FeatureAv The associated FeatureAv object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFeatureAv The associated ChildFeatureAv object. * @throws PropelException */ - public function getFeatureAv(PropelPDO $con = null, $doQuery = true) + public function getFeatureAv(ConnectionInterface $con = null) { - if ($this->aFeatureAv === null && ($this->feature_av_id !== null) && $doQuery) { - $this->aFeatureAv = FeatureAvQuery::create()->findPk($this->feature_av_id, $con); + if ($this->aFeatureAv === null && ($this->feature_av_id !== null)) { + $this->aFeatureAv = ChildFeatureAvQuery::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 @@ -1463,8 +1576,6 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1476,25 +1587,13 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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) { } // if ($deep) $this->aProduct = null; @@ -1503,23 +1602,13 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(FeatureProdTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1527,13 +1616,131 @@ abstract class BaseFeatureProd extends BaseObject implements Persistent /** * 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) + * @return ChildFeatureProd The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = FeatureProdPeer::UPDATED_AT; + $this->modifiedColumns[] = FeatureProdTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php b/core/lib/Thelia/Model/Base/FeatureProdQuery.php old mode 100755 new mode 100644 similarity index 54% rename from core/lib/Thelia/Model/om/BaseFeatureProdQuery.php rename to core/lib/Thelia/Model/Base/FeatureProdQuery.php index 761bacb44..14f5a551b --- a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureProdQuery.php @@ -1,113 +1,111 @@ setModelAlias($modelAlias); } @@ -128,21 +126,21 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return FeatureProd|FeatureProd[]|mixed the result, formatted by the current formatter + * @return ChildFeatureProd|array|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 + if ((null !== ($obj = FeatureProdTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FeatureProdTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -154,46 +152,31 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return FeatureProd A model object, or null if the key is not found - * @throws PropelException + * @return ChildFeatureProd A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FeatureProd(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFeatureProd(); $obj->hydrate($row); - FeatureProdPeer::addInstanceToPool($obj, (string) $key); + FeatureProdTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -204,19 +187,19 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return FeatureProd|FeatureProd[]|mixed the result, formatted by the current formatter + * @return ChildFeatureProd|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -225,22 +208,22 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|FeatureProd[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -248,12 +231,12 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return FeatureProdQuery The current query, for fluid interface + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(FeatureProdPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(FeatureProdTableMap::ID, $key, Criteria::EQUAL); } /** @@ -261,12 +244,12 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return FeatureProdQuery The current query, for fluid interface + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(FeatureProdPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(FeatureProdTableMap::ID, $keys, Criteria::IN); } /** @@ -276,8 +259,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -286,18 +268,18 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * 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 + * @return ChildFeatureProdQuery 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); + $this->addUsingAlias(FeatureProdTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FeatureProdPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureProdTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -308,7 +290,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureProdPeer::ID, $id, $comparison); + return $this->addUsingAlias(FeatureProdTableMap::ID, $id, $comparison); } /** @@ -318,8 +300,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $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 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 * * * @see filterByProduct() @@ -330,18 +311,18 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * 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 + * @return ChildFeatureProdQuery 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); + $this->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($productId['max'])) { - $this->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -352,7 +333,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $productId, $comparison); + return $this->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $productId, $comparison); } /** @@ -362,8 +343,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $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 + * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12 * * * @see filterByFeature() @@ -374,18 +354,18 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * 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 + * @return ChildFeatureProdQuery 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); + $this->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($featureId['max'])) { - $this->addUsingAlias(FeatureProdPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -396,7 +376,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureProdPeer::FEATURE_ID, $featureId, $comparison); + return $this->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $featureId, $comparison); } /** @@ -406,8 +386,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $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 + * $query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id > 12 * * * @see filterByFeatureAv() @@ -418,18 +397,18 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * 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 + * @return ChildFeatureProdQuery 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); + $this->addUsingAlias(FeatureProdTableMap::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); + $this->addUsingAlias(FeatureProdTableMap::FEATURE_AV_ID, $featureAvId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -440,7 +419,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAvId, $comparison); + return $this->addUsingAlias(FeatureProdTableMap::FEATURE_AV_ID, $featureAvId, $comparison); } /** @@ -456,7 +435,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * 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 + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function filterByByDefault($byDefault = null, $comparison = null) { @@ -469,7 +448,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureProdPeer::BY_DEFAULT, $byDefault, $comparison); + return $this->addUsingAlias(FeatureProdTableMap::BY_DEFAULT, $byDefault, $comparison); } /** @@ -479,8 +458,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -489,18 +467,18 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * 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 + * @return ChildFeatureProdQuery 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); + $this->addUsingAlias(FeatureProdTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(FeatureProdPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureProdTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -511,7 +489,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureProdPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(FeatureProdTableMap::POSITION, $position, $comparison); } /** @@ -532,18 +510,18 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * 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 + * @return ChildFeatureProdQuery 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); + $this->addUsingAlias(FeatureProdTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(FeatureProdPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureProdTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -554,7 +532,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureProdPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(FeatureProdTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -575,18 +553,18 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * 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 + * @return ChildFeatureProdQuery 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); + $this->addUsingAlias(FeatureProdTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureProdTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -597,32 +575,31 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } } - return $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(FeatureProdTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureProdTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -632,7 +609,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * @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 + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -661,7 +638,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -677,28 +654,27 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } /** - * Filter the query by a related Feature object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Feature|ObjectCollection $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. + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function filterByFeature($feature, $comparison = null) { - if ($feature instanceof Feature) { + if ($feature instanceof \Thelia\Model\Feature) { return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_ID, $feature->getId(), $comparison); - } elseif ($feature instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $feature->getId(), $comparison); + } elseif ($feature instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureProdTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection'); + throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection'); } } @@ -708,7 +684,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * @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 + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -737,7 +713,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria /** * Use the Feature relation Feature object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -753,28 +729,27 @@ abstract class BaseFeatureProdQuery extends ModelCriteria } /** - * Filter the query by a related FeatureAv object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureAv|ObjectCollection $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. + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function filterByFeatureAv($featureAv, $comparison = null) { - if ($featureAv instanceof FeatureAv) { + if ($featureAv instanceof \Thelia\Model\FeatureAv) { return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->getId(), $comparison); - } elseif ($featureAv instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureProdTableMap::FEATURE_AV_ID, $featureAv->getId(), $comparison); + } elseif ($featureAv instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FeatureProdTableMap::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); + throw new PropelException('filterByFeatureAv() only accepts arguments of type \Thelia\Model\FeatureAv or Collection'); } } @@ -784,7 +759,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * @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 + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function joinFeatureAv($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -813,7 +788,7 @@ abstract class BaseFeatureProdQuery extends ModelCriteria /** * Use the FeatureAv relation FeatureAv object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -831,19 +806,94 @@ abstract class BaseFeatureProdQuery extends ModelCriteria /** * Exclude object from result * - * @param FeatureProd $featureProd Object to remove from the list of results + * @param ChildFeatureProd $featureProd Object to remove from the list of results * - * @return FeatureProdQuery The current query, for fluid interface + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function prune($featureProd = null) { if ($featureProd) { - $this->addUsingAlias(FeatureProdPeer::ID, $featureProd->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(FeatureProdTableMap::ID, $featureProd->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the feature_prod table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FeatureProdTableMap::clearInstancePool(); + FeatureProdTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFeatureProd or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFeatureProd object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FeatureProdTableMap::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(); + + + FeatureProdTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FeatureProdTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -851,31 +901,11 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return FeatureProdQuery The current query, for fluid interface + * @return ChildFeatureProdQuery 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); + return $this->addUsingAlias(FeatureProdTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -883,30 +913,51 @@ abstract class BaseFeatureProdQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return FeatureProdQuery The current query, for fluid interface + * @return ChildFeatureProdQuery 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); + return $this->addUsingAlias(FeatureProdTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildFeatureProdQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureProdTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildFeatureProdQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureProdTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return FeatureProdQuery The current query, for fluid interface + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(FeatureProdPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(FeatureProdTableMap::CREATED_AT); } /** * Order by create date asc * - * @return FeatureProdQuery The current query, for fluid interface + * @return ChildFeatureProdQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(FeatureProdPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(FeatureProdTableMap::CREATED_AT); } -} + +} // FeatureProdQuery diff --git a/core/lib/Thelia/Model/om/BaseFeatureQuery.php b/core/lib/Thelia/Model/Base/FeatureQuery.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseFeatureQuery.php rename to core/lib/Thelia/Model/Base/FeatureQuery.php index f9b008e05..add0494aa --- a/core/lib/Thelia/Model/om/BaseFeatureQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureQuery.php @@ -1,107 +1,104 @@ setModelAlias($modelAlias); } @@ -122,21 +119,21 @@ abstract class BaseFeatureQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Feature|Feature[]|mixed the result, formatted by the current formatter + * @return ChildFeature|array|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 + if ((null !== ($obj = FeatureTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FeatureTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -148,46 +145,31 @@ abstract class BaseFeatureQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Feature A model object, or null if the key is not found - * @throws PropelException + * @return ChildFeature A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `visible`, `position`, `created_at`, `updated_at` FROM `feature` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Feature(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFeature(); $obj->hydrate($row); - FeaturePeer::addInstanceToPool($obj, (string) $key); + FeatureTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -198,19 +180,19 @@ abstract class BaseFeatureQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Feature|Feature[]|mixed the result, formatted by the current formatter + * @return ChildFeature|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -219,22 +201,22 @@ abstract class BaseFeatureQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Feature[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -242,12 +224,12 @@ abstract class BaseFeatureQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return FeatureQuery The current query, for fluid interface + * @return ChildFeatureQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(FeaturePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(FeatureTableMap::ID, $key, Criteria::EQUAL); } /** @@ -255,12 +237,12 @@ abstract class BaseFeatureQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return FeatureQuery The current query, for fluid interface + * @return ChildFeatureQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(FeaturePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(FeatureTableMap::ID, $keys, Criteria::IN); } /** @@ -270,8 +252,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -280,18 +261,18 @@ abstract class BaseFeatureQuery extends ModelCriteria * 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 + * @return ChildFeatureQuery 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); + $this->addUsingAlias(FeatureTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FeaturePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -302,7 +283,7 @@ abstract class BaseFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(FeaturePeer::ID, $id, $comparison); + return $this->addUsingAlias(FeatureTableMap::ID, $id, $comparison); } /** @@ -312,8 +293,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * * $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 + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 * * * @param mixed $visible The value to use as filter. @@ -322,18 +302,18 @@ abstract class BaseFeatureQuery extends ModelCriteria * 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 + * @return ChildFeatureQuery 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); + $this->addUsingAlias(FeatureTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($visible['max'])) { - $this->addUsingAlias(FeaturePeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -344,7 +324,7 @@ abstract class BaseFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(FeaturePeer::VISIBLE, $visible, $comparison); + return $this->addUsingAlias(FeatureTableMap::VISIBLE, $visible, $comparison); } /** @@ -354,8 +334,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -364,18 +343,18 @@ abstract class BaseFeatureQuery extends ModelCriteria * 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 + * @return ChildFeatureQuery 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); + $this->addUsingAlias(FeatureTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(FeaturePeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -386,7 +365,7 @@ abstract class BaseFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(FeaturePeer::POSITION, $position, $comparison); + return $this->addUsingAlias(FeatureTableMap::POSITION, $position, $comparison); } /** @@ -407,18 +386,18 @@ abstract class BaseFeatureQuery extends ModelCriteria * 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 + * @return ChildFeatureQuery 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); + $this->addUsingAlias(FeatureTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -429,7 +408,7 @@ abstract class BaseFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(FeatureTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -450,18 +429,18 @@ abstract class BaseFeatureQuery extends ModelCriteria * 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 + * @return ChildFeatureQuery 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); + $this->addUsingAlias(FeatureTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FeatureTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -472,30 +451,29 @@ abstract class BaseFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(FeatureTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related FeatureAv object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureAv|ObjectCollection $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. + * @return ChildFeatureQuery The current query, for fluid interface */ public function filterByFeatureAv($featureAv, $comparison = null) { - if ($featureAv instanceof FeatureAv) { + if ($featureAv instanceof \Thelia\Model\FeatureAv) { return $this - ->addUsingAlias(FeaturePeer::ID, $featureAv->getFeatureId(), $comparison); - } elseif ($featureAv instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureTableMap::ID, $featureAv->getFeatureId(), $comparison); + } elseif ($featureAv instanceof ObjectCollection) { return $this ->useFeatureAvQuery() ->filterByPrimaryKeys($featureAv->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); + throw new PropelException('filterByFeatureAv() only accepts arguments of type \Thelia\Model\FeatureAv or Collection'); } } @@ -505,7 +483,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * @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 + * @return ChildFeatureQuery The current query, for fluid interface */ public function joinFeatureAv($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -534,7 +512,7 @@ abstract class BaseFeatureQuery extends ModelCriteria /** * Use the FeatureAv relation FeatureAv object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -550,26 +528,25 @@ abstract class BaseFeatureQuery extends ModelCriteria } /** - * Filter the query by a related FeatureProd object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureProd|ObjectCollection $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. + * @return ChildFeatureQuery The current query, for fluid interface */ public function filterByFeatureProd($featureProd, $comparison = null) { - if ($featureProd instanceof FeatureProd) { + if ($featureProd instanceof \Thelia\Model\FeatureProd) { return $this - ->addUsingAlias(FeaturePeer::ID, $featureProd->getFeatureId(), $comparison); - } elseif ($featureProd instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureTableMap::ID, $featureProd->getFeatureId(), $comparison); + } elseif ($featureProd instanceof ObjectCollection) { return $this ->useFeatureProdQuery() ->filterByPrimaryKeys($featureProd->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection'); + throw new PropelException('filterByFeatureProd() only accepts arguments of type \Thelia\Model\FeatureProd or Collection'); } } @@ -579,7 +556,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * @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 + * @return ChildFeatureQuery The current query, for fluid interface */ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -608,7 +585,7 @@ abstract class BaseFeatureQuery extends ModelCriteria /** * Use the FeatureProd relation FeatureProd object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -624,26 +601,25 @@ abstract class BaseFeatureQuery extends ModelCriteria } /** - * Filter the query by a related FeatureCategory object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureCategory|ObjectCollection $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. + * @return ChildFeatureQuery The current query, for fluid interface */ public function filterByFeatureCategory($featureCategory, $comparison = null) { - if ($featureCategory instanceof FeatureCategory) { + if ($featureCategory instanceof \Thelia\Model\FeatureCategory) { return $this - ->addUsingAlias(FeaturePeer::ID, $featureCategory->getFeatureId(), $comparison); - } elseif ($featureCategory instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureTableMap::ID, $featureCategory->getFeatureId(), $comparison); + } elseif ($featureCategory instanceof ObjectCollection) { return $this ->useFeatureCategoryQuery() ->filterByPrimaryKeys($featureCategory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection'); + throw new PropelException('filterByFeatureCategory() only accepts arguments of type \Thelia\Model\FeatureCategory or Collection'); } } @@ -653,7 +629,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * @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 + * @return ChildFeatureQuery The current query, for fluid interface */ public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -682,7 +658,7 @@ abstract class BaseFeatureQuery extends ModelCriteria /** * Use the FeatureCategory relation FeatureCategory object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -698,26 +674,25 @@ abstract class BaseFeatureQuery extends ModelCriteria } /** - * Filter the query by a related FeatureI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureI18n|ObjectCollection $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. + * @return ChildFeatureQuery The current query, for fluid interface */ public function filterByFeatureI18n($featureI18n, $comparison = null) { - if ($featureI18n instanceof FeatureI18n) { + if ($featureI18n instanceof \Thelia\Model\FeatureI18n) { return $this - ->addUsingAlias(FeaturePeer::ID, $featureI18n->getId(), $comparison); - } elseif ($featureI18n instanceof PropelObjectCollection) { + ->addUsingAlias(FeatureTableMap::ID, $featureI18n->getId(), $comparison); + } elseif ($featureI18n instanceof ObjectCollection) { return $this ->useFeatureI18nQuery() ->filterByPrimaryKeys($featureI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFeatureI18n() only accepts arguments of type FeatureI18n or PropelCollection'); + throw new PropelException('filterByFeatureI18n() only accepts arguments of type \Thelia\Model\FeatureI18n or Collection'); } } @@ -727,7 +702,7 @@ abstract class BaseFeatureQuery extends ModelCriteria * @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 + * @return ChildFeatureQuery The current query, for fluid interface */ public function joinFeatureI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -756,7 +731,7 @@ abstract class BaseFeatureQuery extends ModelCriteria /** * Use the FeatureI18n relation FeatureI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -775,10 +750,10 @@ abstract class BaseFeatureQuery extends ModelCriteria * 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 + * @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 + * @return ChildFeatureQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = Criteria::EQUAL) { @@ -791,19 +766,94 @@ abstract class BaseFeatureQuery extends ModelCriteria /** * Exclude object from result * - * @param Feature $feature Object to remove from the list of results + * @param ChildFeature $feature Object to remove from the list of results * - * @return FeatureQuery The current query, for fluid interface + * @return ChildFeatureQuery The current query, for fluid interface */ public function prune($feature = null) { if ($feature) { - $this->addUsingAlias(FeaturePeer::ID, $feature->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(FeatureTableMap::ID, $feature->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the feature table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FeatureTableMap::clearInstancePool(); + FeatureTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFeature or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFeature object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FeatureTableMap::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(); + + + FeatureTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FeatureTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -811,31 +861,11 @@ abstract class BaseFeatureQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return FeatureQuery The current query, for fluid interface + * @return ChildFeatureQuery 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); + return $this->addUsingAlias(FeatureTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -843,32 +873,53 @@ abstract class BaseFeatureQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return FeatureQuery The current query, for fluid interface + * @return ChildFeatureQuery 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); + return $this->addUsingAlias(FeatureTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildFeatureQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FeatureTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildFeatureQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FeatureTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return FeatureQuery The current query, for fluid interface + * @return ChildFeatureQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(FeaturePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(FeatureTableMap::CREATED_AT); } /** * Order by create date asc * - * @return FeatureQuery The current query, for fluid interface + * @return ChildFeatureQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(FeaturePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(FeatureTableMap::CREATED_AT); } + // i18n behavior /** @@ -878,9 +929,9 @@ abstract class BaseFeatureQuery extends ModelCriteria * @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 + * @return ChildFeatureQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureI18n'; @@ -896,9 +947,9 @@ abstract class BaseFeatureQuery extends ModelCriteria * @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 + * @return ChildFeatureQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -917,13 +968,13 @@ abstract class BaseFeatureQuery extends ModelCriteria * @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 + * @return ChildFeatureI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureI18n', 'Thelia\Model\FeatureI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'FeatureI18n', '\Thelia\Model\FeatureI18nQuery'); } -} +} // FeatureQuery diff --git a/core/lib/Thelia/Model/om/BaseFolder.php b/core/lib/Thelia/Model/Base/Folder.php old mode 100755 new mode 100644 similarity index 61% rename from core/lib/Thelia/Model/om/BaseFolder.php rename to core/lib/Thelia/Model/Base/Folder.php index e2fefbb8a..a8bd93633 --- a/core/lib/Thelia/Model/om/BaseFolder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -1,66 +1,74 @@ applyDefaultValues(); } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Folder instance. If + * obj is an instance of Folder, delegates to + * equals(Folder). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Folder The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Folder The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [parent] column value. * - * @return int + * @return int */ public function getParent() { + return $this->parent; } /** * Get the [link] column value. * - * @return string + * @return string */ public function getLink() { + return $this->link; } /** * Get the [visible] column value. * - * @return int + * @return int */ public function getVisible() { + return $this->visible; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -323,89 +570,50 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version] column value. * - * @return int + * @return int */ public function getVersion() { + return $this->version; } @@ -413,67 +621,48 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getVersionCreatedAt($format = NULL) { - 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; + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version_created_by] column value. * - * @return string + * @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) + * @param int $v new value + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = FolderPeer::ID; + $this->modifiedColumns[] = FolderTableMap::ID; } @@ -483,18 +672,18 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [parent] column. * - * @param int $v new value - * @return Folder The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setParent($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->parent !== $v) { $this->parent = $v; - $this->modifiedColumns[] = FolderPeer::PARENT; + $this->modifiedColumns[] = FolderTableMap::PARENT; } @@ -504,18 +693,18 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [link] column. * - * @param string $v new value - * @return Folder The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setLink($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->link !== $v) { $this->link = $v; - $this->modifiedColumns[] = FolderPeer::LINK; + $this->modifiedColumns[] = FolderTableMap::LINK; } @@ -525,18 +714,18 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [visible] column. * - * @param int $v new value - * @return Folder The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setVisible($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->visible !== $v) { $this->visible = $v; - $this->modifiedColumns[] = FolderPeer::VISIBLE; + $this->modifiedColumns[] = FolderTableMap::VISIBLE; } @@ -546,18 +735,18 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return Folder The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = FolderPeer::POSITION; + $this->modifiedColumns[] = FolderTableMap::POSITION; } @@ -567,19 +756,17 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = FolderTableMap::CREATED_AT; } } // if either are not null @@ -590,19 +777,17 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = FolderTableMap::UPDATED_AT; } } // if either are not null @@ -613,18 +798,18 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [version] column. * - * @param int $v new value - * @return Folder The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setVersion($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->version !== $v) { $this->version = $v; - $this->modifiedColumns[] = FolderPeer::VERSION; + $this->modifiedColumns[] = FolderTableMap::VERSION; } @@ -634,19 +819,17 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setVersionCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = FolderTableMap::VERSION_CREATED_AT; } } // if either are not null @@ -657,18 +840,18 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [version_created_by] column. * - * @param string $v new value - * @return Folder The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Folder The current object (for fluent API support) */ public function setVersionCreatedBy($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->version_created_by !== $v) { $this->version_created_by = $v; - $this->modifiedColumns[] = FolderPeer::VERSION_CREATED_BY; + $this->modifiedColumns[] = FolderTableMap::VERSION_CREATED_BY; } @@ -689,7 +872,7 @@ abstract class BaseFolder extends BaseObject implements Persistent return false; } - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -701,26 +884,59 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $this->parent = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)]; + $this->link = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : FolderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FolderTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : FolderTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : FolderTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -728,11 +944,11 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 10; // 10 = FolderPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 10; // 10 = FolderTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Folder object", $e); + throw new PropelException("Error populating \Thelia\Model\Folder object", 0, $e); } } @@ -751,7 +967,6 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -759,12 +974,12 @@ abstract class BaseFolder extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -775,19 +990,19 @@ abstract class BaseFolder extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FolderTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildFolderQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -810,26 +1025,25 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Folder::setDeleted() + * @see Folder::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = FolderQuery::create() + $deleteQuery = ChildFolderQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -854,20 +1068,19 @@ abstract class BaseFolder extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -877,7 +1090,7 @@ abstract class BaseFolder extends BaseObject implements Persistent // versionable behavior if ($this->isVersioningNecessary()) { $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1); - if (!$this->isColumnModified(FolderPeer::VERSION_CREATED_AT)) { + if (!$this->isColumnModified(FolderTableMap::VERSION_CREATED_AT)) { $this->setVersionCreatedAt(time()); } $createVersion = true; // for postSave hook @@ -885,16 +1098,16 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(FolderPeer::CREATED_AT)) { + if (!$this->isColumnModified(FolderTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(FolderPeer::UPDATED_AT)) { + if (!$this->isColumnModified(FolderTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FolderPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(FolderTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -910,7 +1123,7 @@ abstract class BaseFolder extends BaseObject implements Persistent if (isset($createVersion)) { $this->addVersion($con); } - FolderPeer::addInstanceToPool($this); + FolderTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -929,12 +1142,12 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -954,10 +1167,11 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->contentsScheduledForDeletion !== null) { if (!$this->contentsScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->contentsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($remotePk, $pk); } + ContentFolderQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -979,16 +1193,15 @@ abstract class BaseFolder extends BaseObject implements Persistent 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); - } + \Thelia\Model\ImageQuery::create() + ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->imagesScheduledForDeletion = null; } } - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { + if ($this->collImages !== null) { + foreach ($this->collImages as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -997,16 +1210,15 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->documentsScheduledForDeletion !== null) { if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } + \Thelia\Model\DocumentQuery::create() + ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->documentsScheduledForDeletion = null; } } - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { + if ($this->collDocuments !== null) { + foreach ($this->collDocuments as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1015,16 +1227,15 @@ abstract class BaseFolder extends BaseObject implements Persistent 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); - } + \Thelia\Model\RewritingQuery::create() + ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->rewritingsScheduledForDeletion = null; } } - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { + if ($this->collRewritings !== null) { + foreach ($this->collRewritings as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1033,15 +1244,15 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->contentFoldersScheduledForDeletion !== null) { if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { - ContentFolderQuery::create() + \Thelia\Model\ContentFolderQuery::create() ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->contentFoldersScheduledForDeletion = null; } } - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { + if ($this->collContentFolders !== null) { + foreach ($this->collContentFolders as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1050,15 +1261,15 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->folderI18nsScheduledForDeletion !== null) { if (!$this->folderI18nsScheduledForDeletion->isEmpty()) { - FolderI18nQuery::create() + \Thelia\Model\FolderI18nQuery::create() ->filterByPrimaryKeys($this->folderI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->folderI18nsScheduledForDeletion = null; } } - if ($this->collFolderI18ns !== null) { - foreach ($this->collFolderI18ns as $referrerFK) { + if ($this->collFolderI18ns !== null) { + foreach ($this->collFolderI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1067,15 +1278,15 @@ abstract class BaseFolder extends BaseObject implements Persistent if ($this->folderVersionsScheduledForDeletion !== null) { if (!$this->folderVersionsScheduledForDeletion->isEmpty()) { - FolderVersionQuery::create() + \Thelia\Model\FolderVersionQuery::create() ->filterByPrimaryKeys($this->folderVersionsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->folderVersionsScheduledForDeletion = null; } } - if ($this->collFolderVersions !== null) { - foreach ($this->collFolderVersions as $referrerFK) { + if ($this->collFolderVersions !== null) { + foreach ($this->collFolderVersions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1092,55 +1303,55 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = FolderPeer::ID; + $this->modifiedColumns[] = FolderTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FolderPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(FolderTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(FolderPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`parent`'; + if ($this->isColumnModified(FolderTableMap::PARENT)) { + $modifiedColumns[':p' . $index++] = 'PARENT'; } - if ($this->isColumnModified(FolderPeer::LINK)) { - $modifiedColumns[':p' . $index++] = '`link`'; + if ($this->isColumnModified(FolderTableMap::LINK)) { + $modifiedColumns[':p' . $index++] = 'LINK'; } - if ($this->isColumnModified(FolderPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; + if ($this->isColumnModified(FolderTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; } - if ($this->isColumnModified(FolderPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(FolderTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(FolderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(FolderTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(FolderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(FolderTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } - if ($this->isColumnModified(FolderPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`version`'; + if ($this->isColumnModified(FolderTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; } - if ($this->isColumnModified(FolderPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`version_created_at`'; + if ($this->isColumnModified(FolderTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; } - if ($this->isColumnModified(FolderPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`version_created_by`'; + if ($this->isColumnModified(FolderTableMap::VERSION_CREATED_BY)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY'; } $sql = sprintf( - 'INSERT INTO `folder` (%s) VALUES (%s)', + 'INSERT INTO folder (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1149,34 +1360,34 @@ abstract class BaseFolder extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`parent`': + case 'PARENT': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case '`link`': + case 'LINK': $stmt->bindValue($identifier, $this->link, PDO::PARAM_STR); break; - case '`visible`': + case 'VISIBLE': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version`': + 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); + case 'VERSION_CREATED_AT': + $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version_created_by`': + case 'VERSION_CREATED_BY': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1184,13 +1395,13 @@ abstract class BaseFolder extends BaseObject implements Persistent $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -1200,152 +1411,32 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = FolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = FolderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1355,7 +1446,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1403,22 +1494,22 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = FolderTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getParent(), @@ -1431,6 +1522,12 @@ abstract class BaseFolder extends BaseObject implements Persistent $keys[8] => $this->getVersionCreatedAt(), $keys[9] => $this->getVersionCreatedBy(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collImages) { $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1458,27 +1555,27 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = FolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = FolderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1526,17 +1623,17 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = FolderPeer::getFieldNames($keyType); + $keys = FolderTableMap::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]]); @@ -1557,18 +1654,18 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(FolderPeer::DATABASE_NAME); + $criteria = new Criteria(FolderTableMap::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); + if ($this->isColumnModified(FolderTableMap::ID)) $criteria->add(FolderTableMap::ID, $this->id); + if ($this->isColumnModified(FolderTableMap::PARENT)) $criteria->add(FolderTableMap::PARENT, $this->parent); + if ($this->isColumnModified(FolderTableMap::LINK)) $criteria->add(FolderTableMap::LINK, $this->link); + if ($this->isColumnModified(FolderTableMap::VISIBLE)) $criteria->add(FolderTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(FolderTableMap::POSITION)) $criteria->add(FolderTableMap::POSITION, $this->position); + if ($this->isColumnModified(FolderTableMap::CREATED_AT)) $criteria->add(FolderTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FolderTableMap::UPDATED_AT)) $criteria->add(FolderTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(FolderTableMap::VERSION)) $criteria->add(FolderTableMap::VERSION, $this->version); + if ($this->isColumnModified(FolderTableMap::VERSION_CREATED_AT)) $criteria->add(FolderTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(FolderTableMap::VERSION_CREATED_BY)) $criteria->add(FolderTableMap::VERSION_CREATED_BY, $this->version_created_by); return $criteria; } @@ -1583,15 +1680,15 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(FolderPeer::DATABASE_NAME); - $criteria->add(FolderPeer::ID, $this->id); + $criteria = new Criteria(FolderTableMap::DATABASE_NAME); + $criteria->add(FolderTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1601,7 +1698,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1625,9 +1722,9 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1642,12 +1739,10 @@ abstract class BaseFolder extends BaseObject implements Persistent $copyObj->setVersionCreatedAt($this->getVersionCreatedAt()); $copyObj->setVersionCreatedBy($this->getVersionCreatedBy()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1685,8 +1780,6 @@ abstract class BaseFolder extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1703,8 +1796,8 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Folder Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1717,52 +1810,34 @@ abstract class BaseFolder extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('Image' == $relationName) { - $this->initImages(); + return $this->initImages(); } if ('Document' == $relationName) { - $this->initDocuments(); + return $this->initDocuments(); } if ('Rewriting' == $relationName) { - $this->initRewritings(); + return $this->initRewritings(); } if ('ContentFolder' == $relationName) { - $this->initContentFolders(); + return $this->initContentFolders(); } if ('FolderI18n' == $relationName) { - $this->initFolderI18ns(); + return $this->initFolderI18ns(); } if ('FolderVersion' == $relationName) { - $this->initFolderVersions(); + return $this->initFolderVersions(); } } @@ -1772,21 +1847,16 @@ abstract class BaseFolder extends BaseObject implements Persistent * This 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) + * @return void * @see addImages() */ public function clearImages() { - $this->collImages = null; // important to set this to null since that means it is uninitialized - $this->collImagesPartial = null; - - return $this; + $this->collImages = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collImages collection loaded partially - * - * @return void + * Reset is the collImages collection loaded partially. */ public function resetPartialImages($v = true) { @@ -1800,7 +1870,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1810,25 +1880,25 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null !== $this->collImages && !$overrideExisting) { return; } - $this->collImages = new PropelObjectCollection(); - $this->collImages->setModel('Image'); + $this->collImages = new ObjectCollection(); + $this->collImages->setModel('\Thelia\Model\Image'); } /** - * Gets an array of Image objects which contain a foreign key that references this object. + * Gets an array of ChildImage objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFolder is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildImage[] List of ChildImage objects * @throws PropelException */ - public function getImages($criteria = null, PropelPDO $con = null) + public function getImages($criteria = null, ConnectionInterface $con = null) { $partial = $this->collImagesPartial && !$this->isNew(); if (null === $this->collImages || null !== $criteria || $partial) { @@ -1836,29 +1906,31 @@ abstract class BaseFolder extends BaseObject implements Persistent // return empty collection $this->initImages(); } else { - $collImages = ImageQuery::create(null, $criteria) + $collImages = ChildImageQuery::create(null, $criteria) ->filterByFolder($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); + $this->initImages(false); - foreach($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); + foreach ($collImages as $obj) { + if (false == $this->collImages->contains($obj)) { + $this->collImages->append($obj); + } } - } - $this->collImagesPartial = true; + $this->collImagesPartial = true; } $collImages->getInternalIterator()->rewind(); + return $collImages; } - if($partial && $this->collImages) { - foreach($this->collImages as $obj) { - if($obj->isNew()) { + if ($partial && $this->collImages) { + foreach ($this->collImages as $obj) { + if ($obj->isNew()) { $collImages[] = $obj; } } @@ -1878,15 +1950,16 @@ abstract class BaseFolder extends BaseObject implements Persistent * It will 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) + * @param Collection $images A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolder The current object (for fluent API support) */ - public function setImages(PropelCollection $images, PropelPDO $con = null) + public function setImages(Collection $images, ConnectionInterface $con = null) { $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); + + $this->imagesScheduledForDeletion = $imagesToDelete; foreach ($imagesToDelete as $imageRemoved) { $imageRemoved->setFolder(null); @@ -1906,13 +1979,13 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Returns the number of related Image objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Image objects. * @throws PropelException */ - public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collImagesPartial && !$this->isNew(); if (null === $this->collImages || null !== $criteria || $partial) { @@ -1920,10 +1993,11 @@ abstract class BaseFolder extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getImages()); } - $query = ImageQuery::create(null, $criteria); + + $query = ChildImageQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1937,18 +2011,19 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Method called to associate a Image object to this object - * through the Image foreign key attribute. + * Method called to associate a ChildImage object to this object + * through the ChildImage foreign key attribute. * - * @param Image $l Image - * @return Folder The current object (for fluent API support) + * @param ChildImage $l ChildImage + * @return \Thelia\Model\Folder The current object (for fluent API support) */ - public function addImage(Image $l) + public function addImage(ChildImage $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); } @@ -1957,7 +2032,7 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param Image $image The image object to add. + * @param Image $image The image object to add. */ protected function doAddImage($image) { @@ -1966,8 +2041,8 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param Image $image The image object to remove. - * @return Folder The current object (for fluent API support) + * @param Image $image The image object to remove. + * @return ChildFolder The current object (for fluent API support) */ public function removeImage($image) { @@ -1996,15 +2071,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getImages($query, $con); } @@ -2021,15 +2096,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getImages($query, $con); } @@ -2046,15 +2121,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getImages($query, $con); } @@ -2065,21 +2140,16 @@ abstract class BaseFolder extends BaseObject implements Persistent * This 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) + * @return void * @see addDocuments() */ public function clearDocuments() { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - - return $this; + $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collDocuments collection loaded partially - * - * @return void + * Reset is the collDocuments collection loaded partially. */ public function resetPartialDocuments($v = true) { @@ -2093,7 +2163,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2103,25 +2173,25 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null !== $this->collDocuments && !$overrideExisting) { return; } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); + $this->collDocuments = new ObjectCollection(); + $this->collDocuments->setModel('\Thelia\Model\Document'); } /** - * Gets an array of Document objects which contain a foreign key that references this object. + * Gets an array of ChildDocument objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFolder is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildDocument[] List of ChildDocument objects * @throws PropelException */ - public function getDocuments($criteria = null, PropelPDO $con = null) + public function getDocuments($criteria = null, ConnectionInterface $con = null) { $partial = $this->collDocumentsPartial && !$this->isNew(); if (null === $this->collDocuments || null !== $criteria || $partial) { @@ -2129,29 +2199,31 @@ abstract class BaseFolder extends BaseObject implements Persistent // return empty collection $this->initDocuments(); } else { - $collDocuments = DocumentQuery::create(null, $criteria) + $collDocuments = ChildDocumentQuery::create(null, $criteria) ->filterByFolder($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); + $this->initDocuments(false); - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); + foreach ($collDocuments as $obj) { + if (false == $this->collDocuments->contains($obj)) { + $this->collDocuments->append($obj); + } } - } - $this->collDocumentsPartial = true; + $this->collDocumentsPartial = true; } $collDocuments->getInternalIterator()->rewind(); + return $collDocuments; } - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { + if ($partial && $this->collDocuments) { + foreach ($this->collDocuments as $obj) { + if ($obj->isNew()) { $collDocuments[] = $obj; } } @@ -2171,15 +2243,16 @@ abstract class BaseFolder extends BaseObject implements Persistent * It will 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) + * @param Collection $documents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolder The current object (for fluent API support) */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) + public function setDocuments(Collection $documents, ConnectionInterface $con = null) { $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); + + $this->documentsScheduledForDeletion = $documentsToDelete; foreach ($documentsToDelete as $documentRemoved) { $documentRemoved->setFolder(null); @@ -2199,13 +2272,13 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Returns the number of related Document objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Document objects. * @throws PropelException */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collDocumentsPartial && !$this->isNew(); if (null === $this->collDocuments || null !== $criteria || $partial) { @@ -2213,10 +2286,11 @@ abstract class BaseFolder extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getDocuments()); } - $query = DocumentQuery::create(null, $criteria); + + $query = ChildDocumentQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2230,18 +2304,19 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. + * Method called to associate a ChildDocument object to this object + * through the ChildDocument foreign key attribute. * - * @param Document $l Document - * @return Folder The current object (for fluent API support) + * @param ChildDocument $l ChildDocument + * @return \Thelia\Model\Folder The current object (for fluent API support) */ - public function addDocument(Document $l) + public function addDocument(ChildDocument $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); } @@ -2250,7 +2325,7 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param Document $document The document object to add. + * @param Document $document The document object to add. */ protected function doAddDocument($document) { @@ -2259,8 +2334,8 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param Document $document The document object to remove. - * @return Folder The current object (for fluent API support) + * @param Document $document The document object to remove. + * @return ChildFolder The current object (for fluent API support) */ public function removeDocument($document) { @@ -2289,15 +2364,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getDocuments($query, $con); } @@ -2314,15 +2389,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getDocuments($query, $con); } @@ -2339,15 +2414,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getDocuments($query, $con); } @@ -2358,21 +2433,16 @@ abstract class BaseFolder extends BaseObject implements Persistent * This 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) + * @return void * @see addRewritings() */ public function clearRewritings() { - $this->collRewritings = null; // important to set this to null since that means it is uninitialized - $this->collRewritingsPartial = null; - - return $this; + $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collRewritings collection loaded partially - * - * @return void + * Reset is the collRewritings collection loaded partially. */ public function resetPartialRewritings($v = true) { @@ -2386,7 +2456,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2396,25 +2466,25 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null !== $this->collRewritings && !$overrideExisting) { return; } - $this->collRewritings = new PropelObjectCollection(); - $this->collRewritings->setModel('Rewriting'); + $this->collRewritings = new ObjectCollection(); + $this->collRewritings->setModel('\Thelia\Model\Rewriting'); } /** - * Gets an array of Rewriting objects which contain a foreign key that references this object. + * Gets an array of ChildRewriting objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFolder is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildRewriting[] List of ChildRewriting objects * @throws PropelException */ - public function getRewritings($criteria = null, PropelPDO $con = null) + public function getRewritings($criteria = null, ConnectionInterface $con = null) { $partial = $this->collRewritingsPartial && !$this->isNew(); if (null === $this->collRewritings || null !== $criteria || $partial) { @@ -2422,29 +2492,31 @@ abstract class BaseFolder extends BaseObject implements Persistent // return empty collection $this->initRewritings(); } else { - $collRewritings = RewritingQuery::create(null, $criteria) + $collRewritings = ChildRewritingQuery::create(null, $criteria) ->filterByFolder($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); + $this->initRewritings(false); - foreach($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); + foreach ($collRewritings as $obj) { + if (false == $this->collRewritings->contains($obj)) { + $this->collRewritings->append($obj); + } } - } - $this->collRewritingsPartial = true; + $this->collRewritingsPartial = true; } $collRewritings->getInternalIterator()->rewind(); + return $collRewritings; } - if($partial && $this->collRewritings) { - foreach($this->collRewritings as $obj) { - if($obj->isNew()) { + if ($partial && $this->collRewritings) { + foreach ($this->collRewritings as $obj) { + if ($obj->isNew()) { $collRewritings[] = $obj; } } @@ -2464,15 +2536,16 @@ abstract class BaseFolder extends BaseObject implements Persistent * It will 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) + * @param Collection $rewritings A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolder The current object (for fluent API support) */ - public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) + public function setRewritings(Collection $rewritings, ConnectionInterface $con = null) { $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); + + $this->rewritingsScheduledForDeletion = $rewritingsToDelete; foreach ($rewritingsToDelete as $rewritingRemoved) { $rewritingRemoved->setFolder(null); @@ -2492,13 +2565,13 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Returns the number of related Rewriting objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Rewriting objects. * @throws PropelException */ - public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRewritingsPartial && !$this->isNew(); if (null === $this->collRewritings || null !== $criteria || $partial) { @@ -2506,10 +2579,11 @@ abstract class BaseFolder extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getRewritings()); } - $query = RewritingQuery::create(null, $criteria); + + $query = ChildRewritingQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2523,18 +2597,19 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Method called to associate a Rewriting object to this object - * through the Rewriting foreign key attribute. + * Method called to associate a ChildRewriting object to this object + * through the ChildRewriting foreign key attribute. * - * @param Rewriting $l Rewriting - * @return Folder The current object (for fluent API support) + * @param ChildRewriting $l ChildRewriting + * @return \Thelia\Model\Folder The current object (for fluent API support) */ - public function addRewriting(Rewriting $l) + public function addRewriting(ChildRewriting $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); } @@ -2543,7 +2618,7 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param Rewriting $rewriting The rewriting object to add. + * @param Rewriting $rewriting The rewriting object to add. */ protected function doAddRewriting($rewriting) { @@ -2552,8 +2627,8 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return Folder The current object (for fluent API support) + * @param Rewriting $rewriting The rewriting object to remove. + * @return ChildFolder The current object (for fluent API support) */ public function removeRewriting($rewriting) { @@ -2582,15 +2657,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinProduct($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Product', $joinBehavior); return $this->getRewritings($query, $con); } @@ -2607,15 +2682,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getRewritings($query, $con); } @@ -2632,15 +2707,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getRewritings($query, $con); } @@ -2651,21 +2726,16 @@ abstract class BaseFolder extends BaseObject implements Persistent * This 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) + * @return void * @see addContentFolders() */ public function clearContentFolders() { - $this->collContentFolders = null; // important to set this to null since that means it is uninitialized - $this->collContentFoldersPartial = null; - - return $this; + $this->collContentFolders = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collContentFolders collection loaded partially - * - * @return void + * Reset is the collContentFolders collection loaded partially. */ public function resetPartialContentFolders($v = true) { @@ -2679,7 +2749,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2689,25 +2759,25 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null !== $this->collContentFolders && !$overrideExisting) { return; } - $this->collContentFolders = new PropelObjectCollection(); - $this->collContentFolders->setModel('ContentFolder'); + $this->collContentFolders = new ObjectCollection(); + $this->collContentFolders->setModel('\Thelia\Model\ContentFolder'); } /** - * Gets an array of ContentFolder objects which contain a foreign key that references this object. + * Gets an array of ChildContentFolder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFolder is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentFolder[] List of ChildContentFolder objects * @throws PropelException */ - public function getContentFolders($criteria = null, PropelPDO $con = null) + public function getContentFolders($criteria = null, ConnectionInterface $con = null) { $partial = $this->collContentFoldersPartial && !$this->isNew(); if (null === $this->collContentFolders || null !== $criteria || $partial) { @@ -2715,29 +2785,31 @@ abstract class BaseFolder extends BaseObject implements Persistent // return empty collection $this->initContentFolders(); } else { - $collContentFolders = ContentFolderQuery::create(null, $criteria) + $collContentFolders = ChildContentFolderQuery::create(null, $criteria) ->filterByFolder($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collContentFoldersPartial && count($collContentFolders)) { - $this->initContentFolders(false); + $this->initContentFolders(false); - foreach($collContentFolders as $obj) { - if (false == $this->collContentFolders->contains($obj)) { - $this->collContentFolders->append($obj); + foreach ($collContentFolders as $obj) { + if (false == $this->collContentFolders->contains($obj)) { + $this->collContentFolders->append($obj); + } } - } - $this->collContentFoldersPartial = true; + $this->collContentFoldersPartial = true; } $collContentFolders->getInternalIterator()->rewind(); + return $collContentFolders; } - if($partial && $this->collContentFolders) { - foreach($this->collContentFolders as $obj) { - if($obj->isNew()) { + if ($partial && $this->collContentFolders) { + foreach ($this->collContentFolders as $obj) { + if ($obj->isNew()) { $collContentFolders[] = $obj; } } @@ -2757,15 +2829,19 @@ abstract class BaseFolder extends BaseObject implements Persistent * It will 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) + * @param Collection $contentFolders A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolder The current object (for fluent API support) */ - public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) + public function setContentFolders(Collection $contentFolders, ConnectionInterface $con = null) { $contentFoldersToDelete = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); - $this->contentFoldersScheduledForDeletion = unserialize(serialize($contentFoldersToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->contentFoldersScheduledForDeletion = clone $contentFoldersToDelete; foreach ($contentFoldersToDelete as $contentFolderRemoved) { $contentFolderRemoved->setFolder(null); @@ -2785,13 +2861,13 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Returns the number of related ContentFolder objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ContentFolder objects. * @throws PropelException */ - public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countContentFolders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collContentFoldersPartial && !$this->isNew(); if (null === $this->collContentFolders || null !== $criteria || $partial) { @@ -2799,10 +2875,11 @@ abstract class BaseFolder extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getContentFolders()); } - $query = ContentFolderQuery::create(null, $criteria); + + $query = ChildContentFolderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2816,18 +2893,19 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Method called to associate a ContentFolder object to this object - * through the ContentFolder foreign key attribute. + * Method called to associate a ChildContentFolder object to this object + * through the ChildContentFolder foreign key attribute. * - * @param ContentFolder $l ContentFolder - * @return Folder The current object (for fluent API support) + * @param ChildContentFolder $l ChildContentFolder + * @return \Thelia\Model\Folder The current object (for fluent API support) */ - public function addContentFolder(ContentFolder $l) + public function addContentFolder(ChildContentFolder $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); } @@ -2836,7 +2914,7 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param ContentFolder $contentFolder The contentFolder object to add. + * @param ContentFolder $contentFolder The contentFolder object to add. */ protected function doAddContentFolder($contentFolder) { @@ -2845,8 +2923,8 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param ContentFolder $contentFolder The contentFolder object to remove. - * @return Folder The current object (for fluent API support) + * @param ContentFolder $contentFolder The contentFolder object to remove. + * @return ChildFolder The current object (for fluent API support) */ public function removeContentFolder($contentFolder) { @@ -2875,15 +2953,15 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildContentFolder[] List of ChildContentFolder objects */ - public function getContentFoldersJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getContentFoldersJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ContentFolderQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildContentFolderQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getContentFolders($query, $con); } @@ -2894,21 +2972,16 @@ abstract class BaseFolder extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collFolderI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collFolderI18ns collection loaded partially - * - * @return void + * Reset is the collFolderI18ns collection loaded partially. */ public function resetPartialFolderI18ns($v = true) { @@ -2922,7 +2995,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2932,25 +3005,25 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null !== $this->collFolderI18ns && !$overrideExisting) { return; } - $this->collFolderI18ns = new PropelObjectCollection(); - $this->collFolderI18ns->setModel('FolderI18n'); + $this->collFolderI18ns = new ObjectCollection(); + $this->collFolderI18ns->setModel('\Thelia\Model\FolderI18n'); } /** - * Gets an array of FolderI18n objects which contain a foreign key that references this object. + * Gets an array of ChildFolderI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFolder is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFolderI18n[] List of ChildFolderI18n objects * @throws PropelException */ - public function getFolderI18ns($criteria = null, PropelPDO $con = null) + public function getFolderI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFolderI18nsPartial && !$this->isNew(); if (null === $this->collFolderI18ns || null !== $criteria || $partial) { @@ -2958,29 +3031,31 @@ abstract class BaseFolder extends BaseObject implements Persistent // return empty collection $this->initFolderI18ns(); } else { - $collFolderI18ns = FolderI18nQuery::create(null, $criteria) + $collFolderI18ns = ChildFolderI18nQuery::create(null, $criteria) ->filterByFolder($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collFolderI18nsPartial && count($collFolderI18ns)) { - $this->initFolderI18ns(false); + $this->initFolderI18ns(false); - foreach($collFolderI18ns as $obj) { - if (false == $this->collFolderI18ns->contains($obj)) { - $this->collFolderI18ns->append($obj); + foreach ($collFolderI18ns as $obj) { + if (false == $this->collFolderI18ns->contains($obj)) { + $this->collFolderI18ns->append($obj); + } } - } - $this->collFolderI18nsPartial = true; + $this->collFolderI18nsPartial = true; } $collFolderI18ns->getInternalIterator()->rewind(); + return $collFolderI18ns; } - if($partial && $this->collFolderI18ns) { - foreach($this->collFolderI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collFolderI18ns) { + foreach ($this->collFolderI18ns as $obj) { + if ($obj->isNew()) { $collFolderI18ns[] = $obj; } } @@ -3000,15 +3075,19 @@ abstract class BaseFolder extends BaseObject implements Persistent * It will 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) + * @param Collection $folderI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolder The current object (for fluent API support) */ - public function setFolderI18ns(PropelCollection $folderI18ns, PropelPDO $con = null) + public function setFolderI18ns(Collection $folderI18ns, ConnectionInterface $con = null) { $folderI18nsToDelete = $this->getFolderI18ns(new Criteria(), $con)->diff($folderI18ns); - $this->folderI18nsScheduledForDeletion = unserialize(serialize($folderI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->folderI18nsScheduledForDeletion = clone $folderI18nsToDelete; foreach ($folderI18nsToDelete as $folderI18nRemoved) { $folderI18nRemoved->setFolder(null); @@ -3028,13 +3107,13 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Returns the number of related FolderI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FolderI18n objects. * @throws PropelException */ - public function countFolderI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFolderI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFolderI18nsPartial && !$this->isNew(); if (null === $this->collFolderI18ns || null !== $criteria || $partial) { @@ -3042,10 +3121,11 @@ abstract class BaseFolder extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getFolderI18ns()); } - $query = FolderI18nQuery::create(null, $criteria); + + $query = ChildFolderI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3059,13 +3139,13 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Method called to associate a FolderI18n object to this object - * through the FolderI18n foreign key attribute. + * Method called to associate a ChildFolderI18n object to this object + * through the ChildFolderI18n foreign key attribute. * - * @param FolderI18n $l FolderI18n - * @return Folder The current object (for fluent API support) + * @param ChildFolderI18n $l ChildFolderI18n + * @return \Thelia\Model\Folder The current object (for fluent API support) */ - public function addFolderI18n(FolderI18n $l) + public function addFolderI18n(ChildFolderI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -3075,6 +3155,7 @@ abstract class BaseFolder extends BaseObject implements Persistent $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); } @@ -3083,7 +3164,7 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param FolderI18n $folderI18n The folderI18n object to add. + * @param FolderI18n $folderI18n The folderI18n object to add. */ protected function doAddFolderI18n($folderI18n) { @@ -3092,8 +3173,8 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param FolderI18n $folderI18n The folderI18n object to remove. - * @return Folder The current object (for fluent API support) + * @param FolderI18n $folderI18n The folderI18n object to remove. + * @return ChildFolder The current object (for fluent API support) */ public function removeFolderI18n($folderI18n) { @@ -3116,21 +3197,16 @@ abstract class BaseFolder extends BaseObject implements Persistent * This 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) + * @return void * @see addFolderVersions() */ public function clearFolderVersions() { - $this->collFolderVersions = null; // important to set this to null since that means it is uninitialized - $this->collFolderVersionsPartial = null; - - return $this; + $this->collFolderVersions = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collFolderVersions collection loaded partially - * - * @return void + * Reset is the collFolderVersions collection loaded partially. */ public function resetPartialFolderVersions($v = true) { @@ -3144,7 +3220,7 @@ abstract class BaseFolder extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3154,25 +3230,25 @@ abstract class BaseFolder extends BaseObject implements Persistent if (null !== $this->collFolderVersions && !$overrideExisting) { return; } - $this->collFolderVersions = new PropelObjectCollection(); - $this->collFolderVersions->setModel('FolderVersion'); + $this->collFolderVersions = new ObjectCollection(); + $this->collFolderVersions->setModel('\Thelia\Model\FolderVersion'); } /** - * Gets an array of FolderVersion objects which contain a foreign key that references this object. + * Gets an array of ChildFolderVersion objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildFolder is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFolderVersion[] List of ChildFolderVersion objects * @throws PropelException */ - public function getFolderVersions($criteria = null, PropelPDO $con = null) + public function getFolderVersions($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFolderVersionsPartial && !$this->isNew(); if (null === $this->collFolderVersions || null !== $criteria || $partial) { @@ -3180,29 +3256,31 @@ abstract class BaseFolder extends BaseObject implements Persistent // return empty collection $this->initFolderVersions(); } else { - $collFolderVersions = FolderVersionQuery::create(null, $criteria) + $collFolderVersions = ChildFolderVersionQuery::create(null, $criteria) ->filterByFolder($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collFolderVersionsPartial && count($collFolderVersions)) { - $this->initFolderVersions(false); + $this->initFolderVersions(false); - foreach($collFolderVersions as $obj) { - if (false == $this->collFolderVersions->contains($obj)) { - $this->collFolderVersions->append($obj); + foreach ($collFolderVersions as $obj) { + if (false == $this->collFolderVersions->contains($obj)) { + $this->collFolderVersions->append($obj); + } } - } - $this->collFolderVersionsPartial = true; + $this->collFolderVersionsPartial = true; } $collFolderVersions->getInternalIterator()->rewind(); + return $collFolderVersions; } - if($partial && $this->collFolderVersions) { - foreach($this->collFolderVersions as $obj) { - if($obj->isNew()) { + if ($partial && $this->collFolderVersions) { + foreach ($this->collFolderVersions as $obj) { + if ($obj->isNew()) { $collFolderVersions[] = $obj; } } @@ -3222,15 +3300,19 @@ abstract class BaseFolder extends BaseObject implements Persistent * It will 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) + * @param Collection $folderVersions A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolder The current object (for fluent API support) */ - public function setFolderVersions(PropelCollection $folderVersions, PropelPDO $con = null) + public function setFolderVersions(Collection $folderVersions, ConnectionInterface $con = null) { $folderVersionsToDelete = $this->getFolderVersions(new Criteria(), $con)->diff($folderVersions); - $this->folderVersionsScheduledForDeletion = unserialize(serialize($folderVersionsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->folderVersionsScheduledForDeletion = clone $folderVersionsToDelete; foreach ($folderVersionsToDelete as $folderVersionRemoved) { $folderVersionRemoved->setFolder(null); @@ -3250,13 +3332,13 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Returns the number of related FolderVersion objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FolderVersion objects. * @throws PropelException */ - public function countFolderVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFolderVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFolderVersionsPartial && !$this->isNew(); if (null === $this->collFolderVersions || null !== $criteria || $partial) { @@ -3264,10 +3346,11 @@ abstract class BaseFolder extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getFolderVersions()); } - $query = FolderVersionQuery::create(null, $criteria); + + $query = ChildFolderVersionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3281,18 +3364,19 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Method called to associate a FolderVersion object to this object - * through the FolderVersion foreign key attribute. + * Method called to associate a ChildFolderVersion object to this object + * through the ChildFolderVersion foreign key attribute. * - * @param FolderVersion $l FolderVersion - * @return Folder The current object (for fluent API support) + * @param ChildFolderVersion $l ChildFolderVersion + * @return \Thelia\Model\Folder The current object (for fluent API support) */ - public function addFolderVersion(FolderVersion $l) + public function addFolderVersion(ChildFolderVersion $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); } @@ -3301,7 +3385,7 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param FolderVersion $folderVersion The folderVersion object to add. + * @param FolderVersion $folderVersion The folderVersion object to add. */ protected function doAddFolderVersion($folderVersion) { @@ -3310,8 +3394,8 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * @param FolderVersion $folderVersion The folderVersion object to remove. - * @return Folder The current object (for fluent API support) + * @param FolderVersion $folderVersion The folderVersion object to remove. + * @return ChildFolder The current object (for fluent API support) */ public function removeFolderVersion($folderVersion) { @@ -3334,15 +3418,13 @@ abstract class BaseFolder extends BaseObject implements Persistent * This 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) + * @return void * @see addContents() */ public function clearContents() { - $this->collContents = null; // important to set this to null since that means it is uninitialized + $this->collContents = null; // important to set this to NULL since that means it is uninitialized $this->collContentsPartial = null; - - return $this; } /** @@ -3356,33 +3438,33 @@ abstract class BaseFolder extends BaseObject implements Persistent */ public function initContents() { - $this->collContents = new PropelObjectCollection(); - $this->collContents->setModel('Content'); + $this->collContents = new ObjectCollection(); + $this->collContents->setModel('\Thelia\Model\Content'); } /** - * Gets a collection of Content objects related by a many-to-many relationship + * Gets a collection of ChildContent 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 + * If this ChildFolder 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Content[] List of Content objects + * @return ObjectCollection|ChildContent[] List of ChildContent objects */ - public function getContents($criteria = null, PropelPDO $con = null) + public function getContents($criteria = null, ConnectionInterface $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) + $collContents = ChildContentQuery::create(null, $criteria) ->filterByFolder($this) ->find($con); if (null !== $criteria) { @@ -3401,11 +3483,11 @@ abstract class BaseFolder extends BaseObject implements Persistent * It will 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) + * @param Collection $contents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildFolder The current object (for fluent API support) */ - public function setContents(PropelCollection $contents, PropelPDO $con = null) + public function setContents(Collection $contents, ConnectionInterface $con = null) { $this->clearContents(); $currentContents = $this->getContents(); @@ -3424,22 +3506,22 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Gets the number of Content objects related by a many-to-many relationship + * Gets the number of ChildContent 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Content objects + * @return int the number of related ChildContent objects */ - public function countContents($criteria = null, $distinct = false, PropelPDO $con = null) + public function countContents($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collContents || null !== $criteria) { if ($this->isNew() && null === $this->collContents) { return 0; } else { - $query = ContentQuery::create(null, $criteria); + $query = ChildContentQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3454,52 +3536,60 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Associate a Content object to this object + * Associate a ChildContent 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) + * @param ChildContent $content The ChildContentFolder object to relate + * @return ChildFolder The current object (for fluent API support) */ - public function addContent(Content $content) + public function addContent(ChildContent $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; + $this->collContents[] = $content; } return $this; } /** - * @param Content $content The content object to add. + * @param Content $content The content object to add. */ protected function doAddContent($content) { - $contentFolder = new ContentFolder(); + $contentFolder = new ChildContentFolder(); $contentFolder->setContent($content); $this->addContentFolder($contentFolder); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$content->getFolders()->contains($this)) { + $foreignCollection = $content->getFolders(); + $foreignCollection[] = $this; + } } /** - * Remove a Content object to this object + * Remove a ChildContent 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) + * @param ChildContent $content The ChildContentFolder object to relate + * @return ChildFolder The current object (for fluent API support) */ - public function removeContent(Content $content) + public function removeContent(ChildContent $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; + + $this->contentsScheduledForDeletion[] = $content; } return $this; @@ -3521,8 +3611,6 @@ abstract class BaseFolder extends BaseObject implements Persistent $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(); @@ -3535,14 +3623,13 @@ abstract class BaseFolder extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collImages) { foreach ($this->collImages as $o) { $o->clearAllReferences($deep); @@ -3578,62 +3665,50 @@ abstract class BaseFolder extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collImages instanceof PropelCollection) { + if ($this->collImages instanceof Collection) { $this->collImages->clearIterator(); } $this->collImages = null; - if ($this->collDocuments instanceof PropelCollection) { + if ($this->collDocuments instanceof Collection) { $this->collDocuments->clearIterator(); } $this->collDocuments = null; - if ($this->collRewritings instanceof PropelCollection) { + if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } $this->collRewritings = null; - if ($this->collContentFolders instanceof PropelCollection) { + if ($this->collContentFolders instanceof Collection) { $this->collContentFolders->clearIterator(); } $this->collContentFolders = null; - if ($this->collFolderI18ns instanceof PropelCollection) { + if ($this->collFolderI18ns instanceof Collection) { $this->collFolderI18ns->clearIterator(); } $this->collFolderI18ns = null; - if ($this->collFolderVersions instanceof PropelCollection) { + if ($this->collFolderVersions instanceof Collection) { $this->collFolderVersions->clearIterator(); } $this->collFolderVersions = null; - if ($this->collContents instanceof PropelCollection) { + if ($this->collContents instanceof Collection) { $this->collContents->clearIterator(); } $this->collContents = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(FolderTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -3641,11 +3716,11 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * 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) + * @return ChildFolder The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = FolderPeer::UPDATED_AT; + $this->modifiedColumns[] = FolderTableMap::UPDATED_AT; return $this; } @@ -3657,9 +3732,9 @@ abstract class BaseFolder extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Folder The current object (for fluent API support) + * @return ChildFolder The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -3680,10 +3755,10 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return FolderI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildFolderI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFolderI18ns) { @@ -3696,10 +3771,10 @@ abstract class BaseFolder extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new FolderI18n(); + $translation = new ChildFolderI18n(); $translation->setLocale($locale); } else { - $translation = FolderI18nQuery::create() + $translation = ChildFolderI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -3714,14 +3789,14 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Folder The current object (for fluent API support) + * @return ChildFolder The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - FolderI18nQuery::create() + ChildFolderI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -3741,10 +3816,10 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return FolderI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildFolderI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -3753,7 +3828,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -3764,8 +3839,8 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -3777,7 +3852,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -3788,8 +3863,8 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -3801,7 +3876,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -3812,8 +3887,8 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -3825,7 +3900,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -3836,8 +3911,8 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -3850,7 +3925,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Enforce a new Version of this object upon next save. * - * @return Folder + * @return \Thelia\Model\Folder */ public function enforceVersioning() { @@ -3862,8 +3937,6 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * 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) @@ -3876,7 +3949,7 @@ abstract class BaseFolder extends BaseObject implements Persistent return true; } - if (FolderPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) { + if (ChildFolderQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) { return true; } @@ -3886,15 +3959,15 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Creates a version of the current object and saves it. * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return FolderVersion A version object + * @return ChildFolderVersion A version object */ public function addVersion($con = null) { $this->enforceVersion = false; - $version = new FolderVersion(); + $version = new ChildFolderVersion(); $version->setId($this->getId()); $version->setParent($this->getParent()); $version->setLink($this->getLink()); @@ -3912,19 +3985,18 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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 + * @param ConnectionInterface $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. + * @return ChildFolder The current object (for fluent API support) */ 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)); + throw new PropelException(sprintf('No ChildFolder object found with version %d', $version)); } $this->populateFromVersion($version, $con); @@ -3932,18 +4004,17 @@ abstract class BaseFolder extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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. + * @param ChildFolderVersion $version The version object to use + * @param ConnectionInterface $con the connection to use + * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects. * - * @return Folder The current object (for fluent API support) + * @return ChildFolder The current object (for fluent API support) */ public function populateFromVersion($version, $con = null, &$loadedObjects = array()) { - - $loadedObjects['Folder'][$version->getId()][$version->getVersion()] = $this; + $loadedObjects['ChildFolder'][$version->getId()][$version->getVersion()] = $this; $this->setId($version->getId()); $this->setParent($version->getParent()); $this->setLink($version->getLink()); @@ -3961,13 +4032,13 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Gets the latest persisted version number for the current object * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * * @return integer */ public function getLastVersionNumber($con = null) { - $v = FolderVersionQuery::create() + $v = ChildFolderVersionQuery::create() ->filterByFolder($this) ->orderByVersion('desc') ->findOne($con); @@ -3981,9 +4052,9 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Checks whether the current object is the latest one * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return boolean + * @return Boolean */ public function isLastVersion($con = null) { @@ -3994,13 +4065,13 @@ abstract class BaseFolder extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con the connection to use * - * @return FolderVersion A version object + * @return ChildFolderVersion A version object */ public function getOneVersion($versionNumber, $con = null) { - return FolderVersionQuery::create() + return ChildFolderVersionQuery::create() ->filterByFolder($this) ->filterByVersion($versionNumber) ->findOne($con); @@ -4009,14 +4080,14 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Gets all the versions of this object, in incremental order * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return PropelObjectCollection A list of FolderVersion objects + * @return ObjectCollection A list of ChildFolderVersion objects */ public function getAllVersions($con = null) { $criteria = new Criteria(); - $criteria->addAscendingOrderByColumn(FolderVersionPeer::VERSION); + $criteria->addAscendingOrderByColumn(FolderVersionTableMap::VERSION); return $this->getFolderVersions($criteria, $con); } @@ -4031,10 +4102,10 @@ abstract class BaseFolder extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $versionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -4056,11 +4127,11 @@ abstract class BaseFolder extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $fromVersionNumber + * @param integer $toVersionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -4075,7 +4146,7 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * Computes the diff between two versions. * - * print_r($this->computeDiff(1, 2)); + * print_r($book->computeDiff(1, 2)); * => array( * '1' => array('Title' => 'Book title at version 1'), * '2' => array('Title' => 'Book title at version 2') @@ -4124,18 +4195,133 @@ abstract class BaseFolder extends BaseObject implements Persistent /** * 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 + * @param Integer $number the number of record to return. + * @return PropelCollection|array \Thelia\Model\FolderVersion[] List of \Thelia\Model\FolderVersion objects */ - public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null) + public function getLastVersions($number = 10, $criteria = null, $con = null) { - $criteria = FolderVersionQuery::create(null, $criteria); - $criteria->addDescendingOrderByColumn(FolderVersionPeer::VERSION); + $criteria = ChildFolderVersionQuery::create(null, $criteria); + $criteria->addDescendingOrderByColumn(FolderVersionTableMap::VERSION); $criteria->limit($number); return $this->getFolderVersions($criteria, $con); } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/FolderI18n.php b/core/lib/Thelia/Model/Base/FolderI18n.php new file mode 100644 index 000000000..35e69d6a6 --- /dev/null +++ b/core/lib/Thelia/Model/Base/FolderI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\FolderI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FolderI18n instance. If + * obj is an instance of FolderI18n, delegates to + * equals(FolderI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FolderI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FolderI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = FolderI18nTableMap::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 \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = FolderI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = FolderI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = FolderI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = FolderI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = FolderI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = FolderI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\FolderI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(FolderI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildFolderI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aFolder = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see FolderI18n::setDeleted() + * @see FolderI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildFolderI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME); + } + + $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); + FolderI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(FolderI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(FolderI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(FolderI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(FolderI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(FolderI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(FolderI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['FolderI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['FolderI18n'][serialize($this->getPrimaryKey())] = true; + $keys = FolderI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = FolderI18nTableMap::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(FolderI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(FolderI18nTableMap::ID)) $criteria->add(FolderI18nTableMap::ID, $this->id); + if ($this->isColumnModified(FolderI18nTableMap::LOCALE)) $criteria->add(FolderI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(FolderI18nTableMap::TITLE)) $criteria->add(FolderI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(FolderI18nTableMap::DESCRIPTION)) $criteria->add(FolderI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(FolderI18nTableMap::CHAPO)) $criteria->add(FolderI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(FolderI18nTableMap::POSTSCRIPTUM)) $criteria->add(FolderI18nTableMap::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(FolderI18nTableMap::DATABASE_NAME); + $criteria->add(FolderI18nTableMap::ID, $this->id); + $criteria->add(FolderI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildFolder object. + * + * @param ChildFolder $v + * @return \Thelia\Model\FolderI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setFolder(ChildFolder $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 ChildFolder object, it will not be re-added. + if ($v !== null) { + $v->addFolderI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildFolder object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFolder The associated ChildFolder object. + * @throws PropelException + */ + public function getFolder(ConnectionInterface $con = null) + { + if ($this->aFolder === null && ($this->id !== null)) { + $this->aFolder = ChildFolderQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aFolder = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(FolderI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseFolderI18nQuery.php b/core/lib/Thelia/Model/Base/FolderI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseFolderI18nQuery.php rename to core/lib/Thelia/Model/Base/FolderI18nQuery.php index 8f2109c60..bc1e5adf4 --- a/core/lib/Thelia/Model/om/BaseFolderI18nQuery.php +++ b/core/lib/Thelia/Model/Base/FolderI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return FolderI18n|FolderI18n[]|mixed the result, formatted by the current formatter + * @return ChildFolderI18n|array|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 + if ((null !== ($obj = FolderI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(FolderI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FolderI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return FolderI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildFolderI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `folder_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseFolderI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FolderI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFolderI18n(); $obj->hydrate($row); - FolderI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + FolderI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return FolderI18n|FolderI18n[]|mixed the result, formatted by the current formatter + * @return ChildFolderI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|FolderI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return FolderI18nQuery The current query, for fluid interface + * @return ChildFolderI18nQuery 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); + $this->addUsingAlias(FolderI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(FolderI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return FolderI18nQuery The current query, for fluid interface + * @return ChildFolderI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseFolderI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(FolderI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(FolderI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByFolder() @@ -270,18 +266,18 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * 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 + * @return ChildFolderI18nQuery 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); + $this->addUsingAlias(FolderI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FolderI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(FolderI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * 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 + * @return ChildFolderI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(FolderI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * 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 + * @return ChildFolderI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(FolderI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * 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 + * @return ChildFolderI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(FolderI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * 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 + * @return ChildFolderI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(FolderI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * 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 + * @return ChildFolderI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseFolderI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(FolderI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Folder object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Folder|ObjectCollection $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. + * @return ChildFolderI18nQuery The current query, for fluid interface */ public function filterByFolder($folder, $comparison = null) { - if ($folder instanceof Folder) { + if ($folder instanceof \Thelia\Model\Folder) { return $this - ->addUsingAlias(FolderI18nPeer::ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { + ->addUsingAlias(FolderI18nTableMap::ID, $folder->getId(), $comparison); + } elseif ($folder instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FolderI18nPeer::ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FolderI18nTableMap::ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); + throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria * @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 + * @return ChildFolderI18nQuery The current query, for fluid interface */ public function joinFolder($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseFolderI18nQuery extends ModelCriteria /** * Use the Folder relation Folder object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseFolderI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param FolderI18n $folderI18n Object to remove from the list of results + * @param ChildFolderI18n $folderI18n Object to remove from the list of results * - * @return FolderI18nQuery The current query, for fluid interface + * @return ChildFolderI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(FolderI18nTableMap::ID), $folderI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(FolderI18nTableMap::LOCALE), $folderI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the folder_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FolderI18nTableMap::clearInstancePool(); + FolderI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFolderI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFolderI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FolderI18nTableMap::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(); + + + FolderI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FolderI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // FolderI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseFolderQuery.php b/core/lib/Thelia/Model/Base/FolderQuery.php old mode 100755 new mode 100644 similarity index 59% rename from core/lib/Thelia/Model/om/BaseFolderQuery.php rename to core/lib/Thelia/Model/Base/FolderQuery.php index 82fa87ec1..f7d84819d --- a/core/lib/Thelia/Model/om/BaseFolderQuery.php +++ b/core/lib/Thelia/Model/Base/FolderQuery.php @@ -1,137 +1,139 @@ setModelAlias($modelAlias); } @@ -152,21 +154,21 @@ abstract class BaseFolderQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Folder|Folder[]|mixed the result, formatted by the current formatter + * @return ChildFolder|array|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 + if ((null !== ($obj = FolderTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FolderTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -178,46 +180,31 @@ abstract class BaseFolderQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Folder A model object, or null if the key is not found - * @throws PropelException + * @return ChildFolder A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Folder(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFolder(); $obj->hydrate($row); - FolderPeer::addInstanceToPool($obj, (string) $key); + FolderTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -228,19 +215,19 @@ abstract class BaseFolderQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Folder|Folder[]|mixed the result, formatted by the current formatter + * @return ChildFolder|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -249,22 +236,22 @@ abstract class BaseFolderQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Folder[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -272,12 +259,12 @@ abstract class BaseFolderQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return FolderQuery The current query, for fluid interface + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(FolderPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(FolderTableMap::ID, $key, Criteria::EQUAL); } /** @@ -285,12 +272,12 @@ abstract class BaseFolderQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return FolderQuery The current query, for fluid interface + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(FolderPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(FolderTableMap::ID, $keys, Criteria::IN); } /** @@ -300,8 +287,7 @@ abstract class BaseFolderQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -310,18 +296,18 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery 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); + $this->addUsingAlias(FolderTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FolderPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -332,7 +318,7 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::ID, $id, $comparison); + return $this->addUsingAlias(FolderTableMap::ID, $id, $comparison); } /** @@ -342,8 +328,7 @@ abstract class BaseFolderQuery extends ModelCriteria * * $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 + * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 * * * @param mixed $parent The value to use as filter. @@ -352,18 +337,18 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery 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); + $this->addUsingAlias(FolderTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($parent['max'])) { - $this->addUsingAlias(FolderPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -374,7 +359,7 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::PARENT, $parent, $comparison); + return $this->addUsingAlias(FolderTableMap::PARENT, $parent, $comparison); } /** @@ -390,7 +375,7 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByLink($link = null, $comparison = null) { @@ -403,7 +388,7 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::LINK, $link, $comparison); + return $this->addUsingAlias(FolderTableMap::LINK, $link, $comparison); } /** @@ -413,8 +398,7 @@ abstract class BaseFolderQuery extends ModelCriteria * * $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 + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 * * * @param mixed $visible The value to use as filter. @@ -423,18 +407,18 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery 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); + $this->addUsingAlias(FolderTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($visible['max'])) { - $this->addUsingAlias(FolderPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -445,7 +429,7 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::VISIBLE, $visible, $comparison); + return $this->addUsingAlias(FolderTableMap::VISIBLE, $visible, $comparison); } /** @@ -455,8 +439,7 @@ abstract class BaseFolderQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -465,18 +448,18 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery 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); + $this->addUsingAlias(FolderTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(FolderPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -487,7 +470,7 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(FolderTableMap::POSITION, $position, $comparison); } /** @@ -508,18 +491,18 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery 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); + $this->addUsingAlias(FolderTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(FolderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -530,7 +513,7 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(FolderTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -551,18 +534,18 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery 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); + $this->addUsingAlias(FolderTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -573,7 +556,7 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(FolderTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -583,8 +566,7 @@ abstract class BaseFolderQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -593,18 +575,18 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery 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); + $this->addUsingAlias(FolderTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(FolderPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -615,7 +597,7 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::VERSION, $version, $comparison); + return $this->addUsingAlias(FolderTableMap::VERSION, $version, $comparison); } /** @@ -636,18 +618,18 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery 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); + $this->addUsingAlias(FolderTableMap::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); + $this->addUsingAlias(FolderTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -658,7 +640,7 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(FolderTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -674,7 +656,7 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -687,30 +669,29 @@ abstract class BaseFolderQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(FolderTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related Image object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Image|ObjectCollection $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. + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByImage($image, $comparison = null) { - if ($image instanceof Image) { + if ($image instanceof \Thelia\Model\Image) { return $this - ->addUsingAlias(FolderPeer::ID, $image->getFolderId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { + ->addUsingAlias(FolderTableMap::ID, $image->getFolderId(), $comparison); + } elseif ($image instanceof ObjectCollection) { return $this ->useImageQuery() ->filterByPrimaryKeys($image->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); + throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); } } @@ -720,7 +701,7 @@ abstract class BaseFolderQuery extends ModelCriteria * @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 + * @return ChildFolderQuery The current query, for fluid interface */ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -749,7 +730,7 @@ abstract class BaseFolderQuery extends ModelCriteria /** * Use the Image relation Image object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -765,26 +746,25 @@ abstract class BaseFolderQuery extends ModelCriteria } /** - * Filter the query by a related Document object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Document|ObjectCollection $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. + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByDocument($document, $comparison = null) { - if ($document instanceof Document) { + if ($document instanceof \Thelia\Model\Document) { return $this - ->addUsingAlias(FolderPeer::ID, $document->getFolderId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { + ->addUsingAlias(FolderTableMap::ID, $document->getFolderId(), $comparison); + } elseif ($document instanceof ObjectCollection) { return $this ->useDocumentQuery() ->filterByPrimaryKeys($document->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); + throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); } } @@ -794,7 +774,7 @@ abstract class BaseFolderQuery extends ModelCriteria * @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 + * @return ChildFolderQuery The current query, for fluid interface */ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -823,7 +803,7 @@ abstract class BaseFolderQuery extends ModelCriteria /** * Use the Document relation Document object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -839,26 +819,25 @@ abstract class BaseFolderQuery extends ModelCriteria } /** - * Filter the query by a related Rewriting object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Rewriting|ObjectCollection $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. + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByRewriting($rewriting, $comparison = null) { - if ($rewriting instanceof Rewriting) { + if ($rewriting instanceof \Thelia\Model\Rewriting) { return $this - ->addUsingAlias(FolderPeer::ID, $rewriting->getFolderId(), $comparison); - } elseif ($rewriting instanceof PropelObjectCollection) { + ->addUsingAlias(FolderTableMap::ID, $rewriting->getFolderId(), $comparison); + } elseif ($rewriting instanceof ObjectCollection) { return $this ->useRewritingQuery() ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection'); + throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection'); } } @@ -868,7 +847,7 @@ abstract class BaseFolderQuery extends ModelCriteria * @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 + * @return ChildFolderQuery The current query, for fluid interface */ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -897,7 +876,7 @@ abstract class BaseFolderQuery extends ModelCriteria /** * Use the Rewriting relation Rewriting object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -913,26 +892,25 @@ abstract class BaseFolderQuery extends ModelCriteria } /** - * Filter the query by a related ContentFolder object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ContentFolder|ObjectCollection $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. + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByContentFolder($contentFolder, $comparison = null) { - if ($contentFolder instanceof ContentFolder) { + if ($contentFolder instanceof \Thelia\Model\ContentFolder) { return $this - ->addUsingAlias(FolderPeer::ID, $contentFolder->getFolderId(), $comparison); - } elseif ($contentFolder instanceof PropelObjectCollection) { + ->addUsingAlias(FolderTableMap::ID, $contentFolder->getFolderId(), $comparison); + } elseif ($contentFolder instanceof ObjectCollection) { return $this ->useContentFolderQuery() ->filterByPrimaryKeys($contentFolder->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection'); + throw new PropelException('filterByContentFolder() only accepts arguments of type \Thelia\Model\ContentFolder or Collection'); } } @@ -942,7 +920,7 @@ abstract class BaseFolderQuery extends ModelCriteria * @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 + * @return ChildFolderQuery The current query, for fluid interface */ public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -971,7 +949,7 @@ abstract class BaseFolderQuery extends ModelCriteria /** * Use the ContentFolder relation ContentFolder object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -987,26 +965,25 @@ abstract class BaseFolderQuery extends ModelCriteria } /** - * Filter the query by a related FolderI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FolderI18n|ObjectCollection $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. + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByFolderI18n($folderI18n, $comparison = null) { - if ($folderI18n instanceof FolderI18n) { + if ($folderI18n instanceof \Thelia\Model\FolderI18n) { return $this - ->addUsingAlias(FolderPeer::ID, $folderI18n->getId(), $comparison); - } elseif ($folderI18n instanceof PropelObjectCollection) { + ->addUsingAlias(FolderTableMap::ID, $folderI18n->getId(), $comparison); + } elseif ($folderI18n instanceof ObjectCollection) { return $this ->useFolderI18nQuery() ->filterByPrimaryKeys($folderI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFolderI18n() only accepts arguments of type FolderI18n or PropelCollection'); + throw new PropelException('filterByFolderI18n() only accepts arguments of type \Thelia\Model\FolderI18n or Collection'); } } @@ -1016,7 +993,7 @@ abstract class BaseFolderQuery extends ModelCriteria * @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 + * @return ChildFolderQuery The current query, for fluid interface */ public function joinFolderI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -1045,7 +1022,7 @@ abstract class BaseFolderQuery extends ModelCriteria /** * Use the FolderI18n relation FolderI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1061,26 +1038,25 @@ abstract class BaseFolderQuery extends ModelCriteria } /** - * Filter the query by a related FolderVersion object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FolderVersion|ObjectCollection $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. + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByFolderVersion($folderVersion, $comparison = null) { - if ($folderVersion instanceof FolderVersion) { + if ($folderVersion instanceof \Thelia\Model\FolderVersion) { return $this - ->addUsingAlias(FolderPeer::ID, $folderVersion->getId(), $comparison); - } elseif ($folderVersion instanceof PropelObjectCollection) { + ->addUsingAlias(FolderTableMap::ID, $folderVersion->getId(), $comparison); + } elseif ($folderVersion instanceof ObjectCollection) { return $this ->useFolderVersionQuery() ->filterByPrimaryKeys($folderVersion->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFolderVersion() only accepts arguments of type FolderVersion or PropelCollection'); + throw new PropelException('filterByFolderVersion() only accepts arguments of type \Thelia\Model\FolderVersion or Collection'); } } @@ -1090,7 +1066,7 @@ abstract class BaseFolderQuery extends ModelCriteria * @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 + * @return ChildFolderQuery The current query, for fluid interface */ public function joinFolderVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1119,7 +1095,7 @@ abstract class BaseFolderQuery extends ModelCriteria /** * Use the FolderVersion relation FolderVersion object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1138,10 +1114,10 @@ abstract class BaseFolderQuery extends ModelCriteria * 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 + * @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 + * @return ChildFolderQuery The current query, for fluid interface */ public function filterByContent($content, $comparison = Criteria::EQUAL) { @@ -1154,19 +1130,94 @@ abstract class BaseFolderQuery extends ModelCriteria /** * Exclude object from result * - * @param Folder $folder Object to remove from the list of results + * @param ChildFolder $folder Object to remove from the list of results * - * @return FolderQuery The current query, for fluid interface + * @return ChildFolderQuery The current query, for fluid interface */ public function prune($folder = null) { if ($folder) { - $this->addUsingAlias(FolderPeer::ID, $folder->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(FolderTableMap::ID, $folder->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the folder table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FolderTableMap::clearInstancePool(); + FolderTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFolder or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFolder object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FolderTableMap::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(); + + + FolderTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FolderTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -1174,31 +1225,11 @@ abstract class BaseFolderQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return FolderQuery The current query, for fluid interface + * @return ChildFolderQuery 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); + return $this->addUsingAlias(FolderTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -1206,32 +1237,53 @@ abstract class BaseFolderQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return FolderQuery The current query, for fluid interface + * @return ChildFolderQuery 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); + return $this->addUsingAlias(FolderTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildFolderQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(FolderTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildFolderQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(FolderTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return FolderQuery The current query, for fluid interface + * @return ChildFolderQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(FolderPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(FolderTableMap::CREATED_AT); } /** * Order by create date asc * - * @return FolderQuery The current query, for fluid interface + * @return ChildFolderQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(FolderPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(FolderTableMap::CREATED_AT); } + // i18n behavior /** @@ -1241,9 +1293,9 @@ abstract class BaseFolderQuery extends ModelCriteria * @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 + * @return ChildFolderQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FolderI18n'; @@ -1259,9 +1311,9 @@ abstract class BaseFolderQuery extends ModelCriteria * @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 + * @return ChildFolderQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1280,13 +1332,41 @@ abstract class BaseFolderQuery extends ModelCriteria * @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 + * @return ChildFolderI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FolderI18n', 'Thelia\Model\FolderI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'FolderI18n', '\Thelia\Model\FolderI18nQuery'); } -} + // versionable behavior + + /** + * Checks whether versioning is enabled + * + * @return boolean + */ + static public function isVersioningEnabled() + { + return self::$isVersioningEnabled; + } + + /** + * Enables versioning + */ + static public function enableVersioning() + { + self::$isVersioningEnabled = true; + } + + /** + * Disables versioning + */ + static public function disableVersioning() + { + self::$isVersioningEnabled = false; + } + +} // FolderQuery diff --git a/core/lib/Thelia/Model/Base/FolderVersion.php b/core/lib/Thelia/Model/Base/FolderVersion.php new file mode 100644 index 000000000..609d41d9d --- /dev/null +++ b/core/lib/Thelia/Model/Base/FolderVersion.php @@ -0,0 +1,1709 @@ +version = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\FolderVersion object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another FolderVersion instance. If + * obj is an instance of FolderVersion, delegates to + * equals(FolderVersion). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return FolderVersion The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return FolderVersion The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + } + } + + /** + * 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 \Thelia\Model\FolderVersion The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = FolderVersionTableMap::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 \Thelia\Model\FolderVersion The current object (for fluent API support) + */ + public function setParent($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->parent !== $v) { + $this->parent = $v; + $this->modifiedColumns[] = FolderVersionTableMap::PARENT; + } + + + return $this; + } // setParent() + + /** + * Set the value of [link] column. + * + * @param string $v new value + * @return \Thelia\Model\FolderVersion The current object (for fluent API support) + */ + public function setLink($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->link !== $v) { + $this->link = $v; + $this->modifiedColumns[] = FolderVersionTableMap::LINK; + } + + + return $this; + } // setLink() + + /** + * Set the value of [visible] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderVersion The current object (for fluent API support) + */ + public function setVisible($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->visible !== $v) { + $this->visible = $v; + $this->modifiedColumns[] = FolderVersionTableMap::VISIBLE; + } + + + return $this; + } // setVisible() + + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderVersion The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = FolderVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = FolderVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = FolderVersionTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Set the value of [version] column. + * + * @param int $v new value + * @return \Thelia\Model\FolderVersion The current object (for fluent API support) + */ + public function setVersion($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->version !== $v) { + $this->version = $v; + $this->modifiedColumns[] = FolderVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = FolderVersionTableMap::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 \Thelia\Model\FolderVersion The current object (for fluent API support) + */ + public function setVersionCreatedBy($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->version_created_by !== $v) { + $this->version_created_by = $v; + $this->modifiedColumns[] = FolderVersionTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : FolderVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FolderVersionTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $this->parent = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FolderVersionTableMap::translateFieldName('Link', TableMap::TYPE_PHPNAME, $indexType)]; + $this->link = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FolderVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FolderVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FolderVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : FolderVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : FolderVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : FolderVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : FolderVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 10; // 10 = FolderVersionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\FolderVersion object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(FolderVersionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildFolderVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aFolder = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see FolderVersion::setDeleted() + * @see FolderVersion::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildFolderVersionQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME); + } + + $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); + FolderVersionTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(FolderVersionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(FolderVersionTableMap::PARENT)) { + $modifiedColumns[':p' . $index++] = 'PARENT'; + } + if ($this->isColumnModified(FolderVersionTableMap::LINK)) { + $modifiedColumns[':p' . $index++] = 'LINK'; + } + if ($this->isColumnModified(FolderVersionTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; + } + if ($this->isColumnModified(FolderVersionTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(FolderVersionTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(FolderVersionTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + if ($this->isColumnModified(FolderVersionTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; + } + if ($this->isColumnModified(FolderVersionTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; + } + if ($this->isColumnModified(FolderVersionTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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 ? $this->version_created_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderVersionTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['FolderVersion'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['FolderVersion'][serialize($this->getPrimaryKey())] = true; + $keys = FolderVersionTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = FolderVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = FolderVersionTableMap::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(FolderVersionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(FolderVersionTableMap::ID)) $criteria->add(FolderVersionTableMap::ID, $this->id); + if ($this->isColumnModified(FolderVersionTableMap::PARENT)) $criteria->add(FolderVersionTableMap::PARENT, $this->parent); + if ($this->isColumnModified(FolderVersionTableMap::LINK)) $criteria->add(FolderVersionTableMap::LINK, $this->link); + if ($this->isColumnModified(FolderVersionTableMap::VISIBLE)) $criteria->add(FolderVersionTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(FolderVersionTableMap::POSITION)) $criteria->add(FolderVersionTableMap::POSITION, $this->position); + if ($this->isColumnModified(FolderVersionTableMap::CREATED_AT)) $criteria->add(FolderVersionTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(FolderVersionTableMap::UPDATED_AT)) $criteria->add(FolderVersionTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(FolderVersionTableMap::VERSION)) $criteria->add(FolderVersionTableMap::VERSION, $this->version); + if ($this->isColumnModified(FolderVersionTableMap::VERSION_CREATED_AT)) $criteria->add(FolderVersionTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(FolderVersionTableMap::VERSION_CREATED_BY)) $criteria->add(FolderVersionTableMap::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(FolderVersionTableMap::DATABASE_NAME); + $criteria->add(FolderVersionTableMap::ID, $this->id); + $criteria->add(FolderVersionTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildFolder object. + * + * @param ChildFolder $v + * @return \Thelia\Model\FolderVersion The current object (for fluent API support) + * @throws PropelException + */ + public function setFolder(ChildFolder $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 ChildFolder object, it will not be re-added. + if ($v !== null) { + $v->addFolderVersion($this); + } + + + return $this; + } + + + /** + * Get the associated ChildFolder object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFolder The associated ChildFolder object. + * @throws PropelException + */ + public function getFolder(ConnectionInterface $con = null) + { + if ($this->aFolder === null && ($this->id !== null)) { + $this->aFolder = ChildFolderQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aFolder = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(FolderVersionTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php b/core/lib/Thelia/Model/Base/FolderVersionQuery.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseFolderVersionQuery.php rename to core/lib/Thelia/Model/Base/FolderVersionQuery.php index 1c16728b4..8cf9ac440 --- a/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php +++ b/core/lib/Thelia/Model/Base/FolderVersionQuery.php @@ -1,112 +1,111 @@ setModelAlias($modelAlias); } @@ -126,23 +125,22 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * $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 + * @param array[$id, $version] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return FolderVersion|FolderVersion[]|mixed the result, formatted by the current formatter + * @return ChildFolderVersion|array|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 + if ((null !== ($obj = FolderVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(FolderVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(FolderVersionTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -159,14 +157,13 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return FolderVersion A model object, or null if the key is not found - * @throws PropelException + * @return ChildFolderVersion A model object, or null if the key is not found */ 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'; + $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); @@ -174,13 +171,13 @@ abstract class BaseFolderVersionQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FolderVersion(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildFolderVersion(); $obj->hydrate($row); - FolderVersionPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + FolderVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -191,19 +188,19 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return FolderVersion|FolderVersion[]|mixed the result, formatted by the current formatter + * @return ChildFolderVersion|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -212,22 +209,22 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|FolderVersion[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -235,12 +232,12 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return FolderVersionQuery The current query, for fluid interface + * @return ChildFolderVersionQuery 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); + $this->addUsingAlias(FolderVersionTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(FolderVersionTableMap::VERSION, $key[1], Criteria::EQUAL); return $this; } @@ -250,7 +247,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return FolderVersionQuery The current query, for fluid interface + * @return ChildFolderVersionQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -258,8 +255,8 @@ abstract class BaseFolderVersionQuery extends ModelCriteria 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 = $this->getNewCriterion(FolderVersionTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(FolderVersionTableMap::VERSION, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -274,8 +271,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByFolder() @@ -286,18 +282,18 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery 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); + $this->addUsingAlias(FolderVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(FolderVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -308,7 +304,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::ID, $id, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::ID, $id, $comparison); } /** @@ -318,8 +314,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $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 + * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 * * * @param mixed $parent The value to use as filter. @@ -328,18 +323,18 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery 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); + $this->addUsingAlias(FolderVersionTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($parent['max'])) { - $this->addUsingAlias(FolderVersionPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderVersionTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -350,7 +345,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::PARENT, $parent, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::PARENT, $parent, $comparison); } /** @@ -366,7 +361,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery The current query, for fluid interface */ public function filterByLink($link = null, $comparison = null) { @@ -379,7 +374,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::LINK, $link, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::LINK, $link, $comparison); } /** @@ -389,8 +384,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $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 + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 * * * @param mixed $visible The value to use as filter. @@ -399,18 +393,18 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery 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); + $this->addUsingAlias(FolderVersionTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($visible['max'])) { - $this->addUsingAlias(FolderVersionPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderVersionTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -421,7 +415,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::VISIBLE, $visible, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::VISIBLE, $visible, $comparison); } /** @@ -431,8 +425,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -441,18 +434,18 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery 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); + $this->addUsingAlias(FolderVersionTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(FolderVersionPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderVersionTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -463,7 +456,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::POSITION, $position, $comparison); } /** @@ -484,18 +477,18 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery 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); + $this->addUsingAlias(FolderVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(FolderVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -506,7 +499,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -527,18 +520,18 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery 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); + $this->addUsingAlias(FolderVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(FolderVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -549,7 +542,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -559,8 +552,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -569,18 +561,18 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery 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); + $this->addUsingAlias(FolderVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(FolderVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(FolderVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -591,7 +583,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::VERSION, $version, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::VERSION, $version, $comparison); } /** @@ -612,18 +604,18 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery 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); + $this->addUsingAlias(FolderVersionTableMap::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); + $this->addUsingAlias(FolderVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -634,7 +626,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -650,7 +642,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * 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 + * @return ChildFolderVersionQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -663,32 +655,31 @@ abstract class BaseFolderVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(FolderVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(FolderVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related Folder object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Folder|ObjectCollection $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. + * @return ChildFolderVersionQuery The current query, for fluid interface */ public function filterByFolder($folder, $comparison = null) { - if ($folder instanceof Folder) { + if ($folder instanceof \Thelia\Model\Folder) { return $this - ->addUsingAlias(FolderVersionPeer::ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { + ->addUsingAlias(FolderVersionTableMap::ID, $folder->getId(), $comparison); + } elseif ($folder instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(FolderVersionPeer::ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(FolderVersionTableMap::ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); + throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); } } @@ -698,7 +689,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria * @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 + * @return ChildFolderVersionQuery The current query, for fluid interface */ public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -727,7 +718,7 @@ abstract class BaseFolderVersionQuery extends ModelCriteria /** * Use the Folder relation Folder object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -745,19 +736,94 @@ abstract class BaseFolderVersionQuery extends ModelCriteria /** * Exclude object from result * - * @param FolderVersion $folderVersion Object to remove from the list of results + * @param ChildFolderVersion $folderVersion Object to remove from the list of results * - * @return FolderVersionQuery The current query, for fluid interface + * @return ChildFolderVersionQuery 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->addCond('pruneCond0', $this->getAliasedColName(FolderVersionTableMap::ID), $folderVersion->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(FolderVersionTableMap::VERSION), $folderVersion->getVersion(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the folder_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + FolderVersionTableMap::clearInstancePool(); + FolderVersionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildFolderVersion or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildFolderVersion object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(FolderVersionTableMap::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(); + + + FolderVersionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + FolderVersionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // FolderVersionQuery diff --git a/core/lib/Thelia/Model/om/BaseGroup.php b/core/lib/Thelia/Model/Base/Group.php old mode 100755 new mode 100644 similarity index 60% rename from core/lib/Thelia/Model/om/BaseGroup.php rename to core/lib/Thelia/Model/Base/Group.php index 0f300ced6..6b66d5f39 --- a/core/lib/Thelia/Model/om/BaseGroup.php +++ b/core/lib/Thelia/Model/Base/Group.php @@ -1,63 +1,71 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Group instance. If + * obj is an instance of Group, delegates to + * equals(Group). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Group The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Group The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [code] column value. * - * @return string + * @return string */ public function getCode() { + return $this->code; } @@ -211,97 +463,57 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Group The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = GroupPeer::ID; + $this->modifiedColumns[] = GroupTableMap::ID; } @@ -311,18 +523,18 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Set the value of [code] column. * - * @param string $v new value - * @return Group The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Group The current object (for fluent API support) */ public function setCode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->code !== $v) { $this->code = $v; - $this->modifiedColumns[] = GroupPeer::CODE; + $this->modifiedColumns[] = GroupTableMap::CODE; } @@ -332,19 +544,17 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Group The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = GroupTableMap::CREATED_AT; } } // if either are not null @@ -355,19 +565,17 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Group The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = GroupTableMap::UPDATED_AT; } } // if either are not null @@ -385,7 +593,7 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -397,20 +605,38 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -418,11 +644,11 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = GroupPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 4; // 4 = GroupTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Group object", $e); + throw new PropelException("Error populating \Thelia\Model\Group object", 0, $e); } } @@ -441,7 +667,6 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -449,12 +674,12 @@ abstract class BaseGroup extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -465,19 +690,19 @@ abstract class BaseGroup extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(GroupTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildGroupQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -497,26 +722,25 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Group::setDeleted() + * @see Group::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = GroupQuery::create() + $deleteQuery = ChildGroupQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -541,20 +765,19 @@ abstract class BaseGroup extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -564,16 +787,16 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(GroupPeer::CREATED_AT)) { + if (!$this->isColumnModified(GroupTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(GroupPeer::UPDATED_AT)) { + if (!$this->isColumnModified(GroupTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(GroupPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(GroupTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -585,7 +808,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - GroupPeer::addInstanceToPool($this); + GroupTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -604,12 +827,12 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -629,10 +852,11 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->adminsScheduledForDeletion !== null) { if (!$this->adminsScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->adminsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($pk, $remotePk); } + AdminGroupQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -655,10 +879,11 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->resourcesScheduledForDeletion !== null) { if (!$this->resourcesScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->resourcesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($pk, $remotePk); } + GroupResourceQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -680,15 +905,15 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->adminGroupsScheduledForDeletion !== null) { if (!$this->adminGroupsScheduledForDeletion->isEmpty()) { - AdminGroupQuery::create() + \Thelia\Model\AdminGroupQuery::create() ->filterByPrimaryKeys($this->adminGroupsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->adminGroupsScheduledForDeletion = null; } } - if ($this->collAdminGroups !== null) { - foreach ($this->collAdminGroups as $referrerFK) { + if ($this->collAdminGroups !== null) { + foreach ($this->collAdminGroups as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -697,15 +922,15 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->groupResourcesScheduledForDeletion !== null) { if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { - GroupResourceQuery::create() + \Thelia\Model\GroupResourceQuery::create() ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->groupResourcesScheduledForDeletion = null; } } - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { + if ($this->collGroupResources !== null) { + foreach ($this->collGroupResources as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -714,15 +939,15 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->groupModulesScheduledForDeletion !== null) { if (!$this->groupModulesScheduledForDeletion->isEmpty()) { - GroupModuleQuery::create() + \Thelia\Model\GroupModuleQuery::create() ->filterByPrimaryKeys($this->groupModulesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->groupModulesScheduledForDeletion = null; } } - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { + if ($this->collGroupModules !== null) { + foreach ($this->collGroupModules as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -731,15 +956,15 @@ abstract class BaseGroup extends BaseObject implements Persistent if ($this->groupI18nsScheduledForDeletion !== null) { if (!$this->groupI18nsScheduledForDeletion->isEmpty()) { - GroupI18nQuery::create() + \Thelia\Model\GroupI18nQuery::create() ->filterByPrimaryKeys($this->groupI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->groupI18nsScheduledForDeletion = null; } } - if ($this->collGroupI18ns !== null) { - foreach ($this->collGroupI18ns as $referrerFK) { + if ($this->collGroupI18ns !== null) { + foreach ($this->collGroupI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -756,37 +981,37 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = GroupPeer::ID; + $this->modifiedColumns[] = GroupTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(GroupPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(GroupTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(GroupPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; + if ($this->isColumnModified(GroupTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(GroupPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(GroupTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(GroupPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(GroupTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `group` (%s) VALUES (%s)', + 'INSERT INTO group (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -795,30 +1020,30 @@ abstract class BaseGroup extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`code`': + case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -828,136 +1053,32 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = GroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = GroupTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -967,7 +1088,7 @@ abstract class BaseGroup extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -997,28 +1118,34 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = GroupTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), $keys[2] => $this->getCreatedAt(), $keys[3] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collAdminGroups) { $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1040,27 +1167,27 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = GroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = GroupTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1090,17 +1217,17 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = GroupPeer::getFieldNames($keyType); + $keys = GroupTableMap::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]]); @@ -1115,12 +1242,12 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(GroupPeer::DATABASE_NAME); + $criteria = new Criteria(GroupTableMap::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); + if ($this->isColumnModified(GroupTableMap::ID)) $criteria->add(GroupTableMap::ID, $this->id); + if ($this->isColumnModified(GroupTableMap::CODE)) $criteria->add(GroupTableMap::CODE, $this->code); + if ($this->isColumnModified(GroupTableMap::CREATED_AT)) $criteria->add(GroupTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(GroupTableMap::UPDATED_AT)) $criteria->add(GroupTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1135,15 +1262,15 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(GroupPeer::DATABASE_NAME); - $criteria->add(GroupPeer::ID, $this->id); + $criteria = new Criteria(GroupTableMap::DATABASE_NAME); + $criteria->add(GroupTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1153,7 +1280,7 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1177,9 +1304,9 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1188,12 +1315,10 @@ abstract class BaseGroup extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1219,8 +1344,6 @@ abstract class BaseGroup extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1237,8 +1360,8 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Group Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1251,46 +1374,28 @@ abstract class BaseGroup extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('AdminGroup' == $relationName) { - $this->initAdminGroups(); + return $this->initAdminGroups(); } if ('GroupResource' == $relationName) { - $this->initGroupResources(); + return $this->initGroupResources(); } if ('GroupModule' == $relationName) { - $this->initGroupModules(); + return $this->initGroupModules(); } if ('GroupI18n' == $relationName) { - $this->initGroupI18ns(); + return $this->initGroupI18ns(); } } @@ -1300,21 +1405,16 @@ abstract class BaseGroup extends BaseObject implements Persistent * This 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) + * @return void * @see addAdminGroups() */ public function clearAdminGroups() { - $this->collAdminGroups = null; // important to set this to null since that means it is uninitialized - $this->collAdminGroupsPartial = null; - - return $this; + $this->collAdminGroups = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collAdminGroups collection loaded partially - * - * @return void + * Reset is the collAdminGroups collection loaded partially. */ public function resetPartialAdminGroups($v = true) { @@ -1328,7 +1428,7 @@ abstract class BaseGroup extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1338,25 +1438,25 @@ abstract class BaseGroup extends BaseObject implements Persistent if (null !== $this->collAdminGroups && !$overrideExisting) { return; } - $this->collAdminGroups = new PropelObjectCollection(); - $this->collAdminGroups->setModel('AdminGroup'); + $this->collAdminGroups = new ObjectCollection(); + $this->collAdminGroups->setModel('\Thelia\Model\AdminGroup'); } /** - * Gets an array of AdminGroup objects which contain a foreign key that references this object. + * Gets an array of ChildAdminGroup objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildGroup is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects * @throws PropelException */ - public function getAdminGroups($criteria = null, PropelPDO $con = null) + public function getAdminGroups($criteria = null, ConnectionInterface $con = null) { $partial = $this->collAdminGroupsPartial && !$this->isNew(); if (null === $this->collAdminGroups || null !== $criteria || $partial) { @@ -1364,29 +1464,31 @@ abstract class BaseGroup extends BaseObject implements Persistent // return empty collection $this->initAdminGroups(); } else { - $collAdminGroups = AdminGroupQuery::create(null, $criteria) + $collAdminGroups = ChildAdminGroupQuery::create(null, $criteria) ->filterByGroup($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) { - $this->initAdminGroups(false); + $this->initAdminGroups(false); - foreach($collAdminGroups as $obj) { - if (false == $this->collAdminGroups->contains($obj)) { - $this->collAdminGroups->append($obj); + foreach ($collAdminGroups as $obj) { + if (false == $this->collAdminGroups->contains($obj)) { + $this->collAdminGroups->append($obj); + } } - } - $this->collAdminGroupsPartial = true; + $this->collAdminGroupsPartial = true; } $collAdminGroups->getInternalIterator()->rewind(); + return $collAdminGroups; } - if($partial && $this->collAdminGroups) { - foreach($this->collAdminGroups as $obj) { - if($obj->isNew()) { + if ($partial && $this->collAdminGroups) { + foreach ($this->collAdminGroups as $obj) { + if ($obj->isNew()) { $collAdminGroups[] = $obj; } } @@ -1406,15 +1508,19 @@ abstract class BaseGroup extends BaseObject implements Persistent * It will 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) + * @param Collection $adminGroups A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildGroup The current object (for fluent API support) */ - public function setAdminGroups(PropelCollection $adminGroups, PropelPDO $con = null) + public function setAdminGroups(Collection $adminGroups, ConnectionInterface $con = null) { $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); - $this->adminGroupsScheduledForDeletion = unserialize(serialize($adminGroupsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->adminGroupsScheduledForDeletion = clone $adminGroupsToDelete; foreach ($adminGroupsToDelete as $adminGroupRemoved) { $adminGroupRemoved->setGroup(null); @@ -1434,13 +1540,13 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Returns the number of related AdminGroup objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related AdminGroup objects. * @throws PropelException */ - public function countAdminGroups(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAdminGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collAdminGroupsPartial && !$this->isNew(); if (null === $this->collAdminGroups || null !== $criteria || $partial) { @@ -1448,10 +1554,11 @@ abstract class BaseGroup extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getAdminGroups()); } - $query = AdminGroupQuery::create(null, $criteria); + + $query = ChildAdminGroupQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1465,18 +1572,19 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * Method called to associate a AdminGroup object to this object - * through the AdminGroup foreign key attribute. + * Method called to associate a ChildAdminGroup object to this object + * through the ChildAdminGroup foreign key attribute. * - * @param AdminGroup $l AdminGroup - * @return Group The current object (for fluent API support) + * @param ChildAdminGroup $l ChildAdminGroup + * @return \Thelia\Model\Group The current object (for fluent API support) */ - public function addAdminGroup(AdminGroup $l) + public function addAdminGroup(ChildAdminGroup $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); } @@ -1485,7 +1593,7 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * @param AdminGroup $adminGroup The adminGroup object to add. + * @param AdminGroup $adminGroup The adminGroup object to add. */ protected function doAddAdminGroup($adminGroup) { @@ -1494,8 +1602,8 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * @param AdminGroup $adminGroup The adminGroup object to remove. - * @return Group The current object (for fluent API support) + * @param AdminGroup $adminGroup The adminGroup object to remove. + * @return ChildGroup The current object (for fluent API support) */ public function removeAdminGroup($adminGroup) { @@ -1524,15 +1632,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects */ - public function getAdminGroupsJoinAdmin($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getAdminGroupsJoinAdmin($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = AdminGroupQuery::create(null, $criteria); - $query->joinWith('Admin', $join_behavior); + $query = ChildAdminGroupQuery::create(null, $criteria); + $query->joinWith('Admin', $joinBehavior); return $this->getAdminGroups($query, $con); } @@ -1543,21 +1651,16 @@ abstract class BaseGroup extends BaseObject implements Persistent * This 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) + * @return void * @see addGroupResources() */ public function clearGroupResources() { - $this->collGroupResources = null; // important to set this to null since that means it is uninitialized - $this->collGroupResourcesPartial = null; - - return $this; + $this->collGroupResources = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collGroupResources collection loaded partially - * - * @return void + * Reset is the collGroupResources collection loaded partially. */ public function resetPartialGroupResources($v = true) { @@ -1571,7 +1674,7 @@ abstract class BaseGroup extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1581,25 +1684,25 @@ abstract class BaseGroup extends BaseObject implements Persistent if (null !== $this->collGroupResources && !$overrideExisting) { return; } - $this->collGroupResources = new PropelObjectCollection(); - $this->collGroupResources->setModel('GroupResource'); + $this->collGroupResources = new ObjectCollection(); + $this->collGroupResources->setModel('\Thelia\Model\GroupResource'); } /** - * Gets an array of GroupResource objects which contain a foreign key that references this object. + * Gets an array of ChildGroupResource objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildGroup is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildGroupResource[] List of ChildGroupResource objects * @throws PropelException */ - public function getGroupResources($criteria = null, PropelPDO $con = null) + public function getGroupResources($criteria = null, ConnectionInterface $con = null) { $partial = $this->collGroupResourcesPartial && !$this->isNew(); if (null === $this->collGroupResources || null !== $criteria || $partial) { @@ -1607,29 +1710,31 @@ abstract class BaseGroup extends BaseObject implements Persistent // return empty collection $this->initGroupResources(); } else { - $collGroupResources = GroupResourceQuery::create(null, $criteria) + $collGroupResources = ChildGroupResourceQuery::create(null, $criteria) ->filterByGroup($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) { - $this->initGroupResources(false); + $this->initGroupResources(false); - foreach($collGroupResources as $obj) { - if (false == $this->collGroupResources->contains($obj)) { - $this->collGroupResources->append($obj); + foreach ($collGroupResources as $obj) { + if (false == $this->collGroupResources->contains($obj)) { + $this->collGroupResources->append($obj); + } } - } - $this->collGroupResourcesPartial = true; + $this->collGroupResourcesPartial = true; } $collGroupResources->getInternalIterator()->rewind(); + return $collGroupResources; } - if($partial && $this->collGroupResources) { - foreach($this->collGroupResources as $obj) { - if($obj->isNew()) { + if ($partial && $this->collGroupResources) { + foreach ($this->collGroupResources as $obj) { + if ($obj->isNew()) { $collGroupResources[] = $obj; } } @@ -1649,15 +1754,19 @@ abstract class BaseGroup extends BaseObject implements Persistent * It will 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) + * @param Collection $groupResources A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildGroup The current object (for fluent API support) */ - public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null) + public function setGroupResources(Collection $groupResources, ConnectionInterface $con = null) { $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); - $this->groupResourcesScheduledForDeletion = unserialize(serialize($groupResourcesToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->groupResourcesScheduledForDeletion = clone $groupResourcesToDelete; foreach ($groupResourcesToDelete as $groupResourceRemoved) { $groupResourceRemoved->setGroup(null); @@ -1677,13 +1786,13 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Returns the number of related GroupResource objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related GroupResource objects. * @throws PropelException */ - public function countGroupResources(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countGroupResources(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collGroupResourcesPartial && !$this->isNew(); if (null === $this->collGroupResources || null !== $criteria || $partial) { @@ -1691,10 +1800,11 @@ abstract class BaseGroup extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getGroupResources()); } - $query = GroupResourceQuery::create(null, $criteria); + + $query = ChildGroupResourceQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1708,18 +1818,19 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * Method called to associate a GroupResource object to this object - * through the GroupResource foreign key attribute. + * Method called to associate a ChildGroupResource object to this object + * through the ChildGroupResource foreign key attribute. * - * @param GroupResource $l GroupResource - * @return Group The current object (for fluent API support) + * @param ChildGroupResource $l ChildGroupResource + * @return \Thelia\Model\Group The current object (for fluent API support) */ - public function addGroupResource(GroupResource $l) + public function addGroupResource(ChildGroupResource $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); } @@ -1728,7 +1839,7 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * @param GroupResource $groupResource The groupResource object to add. + * @param GroupResource $groupResource The groupResource object to add. */ protected function doAddGroupResource($groupResource) { @@ -1737,8 +1848,8 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * @param GroupResource $groupResource The groupResource object to remove. - * @return Group The current object (for fluent API support) + * @param GroupResource $groupResource The groupResource object to remove. + * @return ChildGroup The current object (for fluent API support) */ public function removeGroupResource($groupResource) { @@ -1767,15 +1878,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildGroupResource[] List of ChildGroupResource objects */ - public function getGroupResourcesJoinResource($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getGroupResourcesJoinResource($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = GroupResourceQuery::create(null, $criteria); - $query->joinWith('Resource', $join_behavior); + $query = ChildGroupResourceQuery::create(null, $criteria); + $query->joinWith('Resource', $joinBehavior); return $this->getGroupResources($query, $con); } @@ -1786,21 +1897,16 @@ abstract class BaseGroup extends BaseObject implements Persistent * This 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) + * @return void * @see addGroupModules() */ public function clearGroupModules() { - $this->collGroupModules = null; // important to set this to null since that means it is uninitialized - $this->collGroupModulesPartial = null; - - return $this; + $this->collGroupModules = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collGroupModules collection loaded partially - * - * @return void + * Reset is the collGroupModules collection loaded partially. */ public function resetPartialGroupModules($v = true) { @@ -1814,7 +1920,7 @@ abstract class BaseGroup extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1824,25 +1930,25 @@ abstract class BaseGroup extends BaseObject implements Persistent if (null !== $this->collGroupModules && !$overrideExisting) { return; } - $this->collGroupModules = new PropelObjectCollection(); - $this->collGroupModules->setModel('GroupModule'); + $this->collGroupModules = new ObjectCollection(); + $this->collGroupModules->setModel('\Thelia\Model\GroupModule'); } /** - * Gets an array of GroupModule objects which contain a foreign key that references this object. + * Gets an array of ChildGroupModule objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildGroup is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildGroupModule[] List of ChildGroupModule objects * @throws PropelException */ - public function getGroupModules($criteria = null, PropelPDO $con = null) + public function getGroupModules($criteria = null, ConnectionInterface $con = null) { $partial = $this->collGroupModulesPartial && !$this->isNew(); if (null === $this->collGroupModules || null !== $criteria || $partial) { @@ -1850,29 +1956,31 @@ abstract class BaseGroup extends BaseObject implements Persistent // return empty collection $this->initGroupModules(); } else { - $collGroupModules = GroupModuleQuery::create(null, $criteria) + $collGroupModules = ChildGroupModuleQuery::create(null, $criteria) ->filterByGroup($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collGroupModulesPartial && count($collGroupModules)) { - $this->initGroupModules(false); + $this->initGroupModules(false); - foreach($collGroupModules as $obj) { - if (false == $this->collGroupModules->contains($obj)) { - $this->collGroupModules->append($obj); + foreach ($collGroupModules as $obj) { + if (false == $this->collGroupModules->contains($obj)) { + $this->collGroupModules->append($obj); + } } - } - $this->collGroupModulesPartial = true; + $this->collGroupModulesPartial = true; } $collGroupModules->getInternalIterator()->rewind(); + return $collGroupModules; } - if($partial && $this->collGroupModules) { - foreach($this->collGroupModules as $obj) { - if($obj->isNew()) { + if ($partial && $this->collGroupModules) { + foreach ($this->collGroupModules as $obj) { + if ($obj->isNew()) { $collGroupModules[] = $obj; } } @@ -1892,15 +2000,16 @@ abstract class BaseGroup extends BaseObject implements Persistent * It will 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) + * @param Collection $groupModules A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildGroup The current object (for fluent API support) */ - public function setGroupModules(PropelCollection $groupModules, PropelPDO $con = null) + public function setGroupModules(Collection $groupModules, ConnectionInterface $con = null) { $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); - $this->groupModulesScheduledForDeletion = unserialize(serialize($groupModulesToDelete)); + + $this->groupModulesScheduledForDeletion = $groupModulesToDelete; foreach ($groupModulesToDelete as $groupModuleRemoved) { $groupModuleRemoved->setGroup(null); @@ -1920,13 +2029,13 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Returns the number of related GroupModule objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related GroupModule objects. * @throws PropelException */ - public function countGroupModules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countGroupModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collGroupModulesPartial && !$this->isNew(); if (null === $this->collGroupModules || null !== $criteria || $partial) { @@ -1934,10 +2043,11 @@ abstract class BaseGroup extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getGroupModules()); } - $query = GroupModuleQuery::create(null, $criteria); + + $query = ChildGroupModuleQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1951,18 +2061,19 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * Method called to associate a GroupModule object to this object - * through the GroupModule foreign key attribute. + * Method called to associate a ChildGroupModule object to this object + * through the ChildGroupModule foreign key attribute. * - * @param GroupModule $l GroupModule - * @return Group The current object (for fluent API support) + * @param ChildGroupModule $l ChildGroupModule + * @return \Thelia\Model\Group The current object (for fluent API support) */ - public function addGroupModule(GroupModule $l) + public function addGroupModule(ChildGroupModule $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); } @@ -1971,7 +2082,7 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * @param GroupModule $groupModule The groupModule object to add. + * @param GroupModule $groupModule The groupModule object to add. */ protected function doAddGroupModule($groupModule) { @@ -1980,8 +2091,8 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * @param GroupModule $groupModule The groupModule object to remove. - * @return Group The current object (for fluent API support) + * @param GroupModule $groupModule The groupModule object to remove. + * @return ChildGroup The current object (for fluent API support) */ public function removeGroupModule($groupModule) { @@ -2010,15 +2121,15 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildGroupModule[] List of ChildGroupModule objects */ - public function getGroupModulesJoinModule($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getGroupModulesJoinModule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = GroupModuleQuery::create(null, $criteria); - $query->joinWith('Module', $join_behavior); + $query = ChildGroupModuleQuery::create(null, $criteria); + $query->joinWith('Module', $joinBehavior); return $this->getGroupModules($query, $con); } @@ -2029,21 +2140,16 @@ abstract class BaseGroup extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collGroupI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collGroupI18ns collection loaded partially - * - * @return void + * Reset is the collGroupI18ns collection loaded partially. */ public function resetPartialGroupI18ns($v = true) { @@ -2057,7 +2163,7 @@ abstract class BaseGroup extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2067,25 +2173,25 @@ abstract class BaseGroup extends BaseObject implements Persistent if (null !== $this->collGroupI18ns && !$overrideExisting) { return; } - $this->collGroupI18ns = new PropelObjectCollection(); - $this->collGroupI18ns->setModel('GroupI18n'); + $this->collGroupI18ns = new ObjectCollection(); + $this->collGroupI18ns->setModel('\Thelia\Model\GroupI18n'); } /** - * Gets an array of GroupI18n objects which contain a foreign key that references this object. + * Gets an array of ChildGroupI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildGroup is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildGroupI18n[] List of ChildGroupI18n objects * @throws PropelException */ - public function getGroupI18ns($criteria = null, PropelPDO $con = null) + public function getGroupI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collGroupI18nsPartial && !$this->isNew(); if (null === $this->collGroupI18ns || null !== $criteria || $partial) { @@ -2093,29 +2199,31 @@ abstract class BaseGroup extends BaseObject implements Persistent // return empty collection $this->initGroupI18ns(); } else { - $collGroupI18ns = GroupI18nQuery::create(null, $criteria) + $collGroupI18ns = ChildGroupI18nQuery::create(null, $criteria) ->filterByGroup($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collGroupI18nsPartial && count($collGroupI18ns)) { - $this->initGroupI18ns(false); + $this->initGroupI18ns(false); - foreach($collGroupI18ns as $obj) { - if (false == $this->collGroupI18ns->contains($obj)) { - $this->collGroupI18ns->append($obj); + foreach ($collGroupI18ns as $obj) { + if (false == $this->collGroupI18ns->contains($obj)) { + $this->collGroupI18ns->append($obj); + } } - } - $this->collGroupI18nsPartial = true; + $this->collGroupI18nsPartial = true; } $collGroupI18ns->getInternalIterator()->rewind(); + return $collGroupI18ns; } - if($partial && $this->collGroupI18ns) { - foreach($this->collGroupI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collGroupI18ns) { + foreach ($this->collGroupI18ns as $obj) { + if ($obj->isNew()) { $collGroupI18ns[] = $obj; } } @@ -2135,15 +2243,19 @@ abstract class BaseGroup extends BaseObject implements Persistent * It will 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) + * @param Collection $groupI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildGroup The current object (for fluent API support) */ - public function setGroupI18ns(PropelCollection $groupI18ns, PropelPDO $con = null) + public function setGroupI18ns(Collection $groupI18ns, ConnectionInterface $con = null) { $groupI18nsToDelete = $this->getGroupI18ns(new Criteria(), $con)->diff($groupI18ns); - $this->groupI18nsScheduledForDeletion = unserialize(serialize($groupI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->groupI18nsScheduledForDeletion = clone $groupI18nsToDelete; foreach ($groupI18nsToDelete as $groupI18nRemoved) { $groupI18nRemoved->setGroup(null); @@ -2163,13 +2275,13 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Returns the number of related GroupI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related GroupI18n objects. * @throws PropelException */ - public function countGroupI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countGroupI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collGroupI18nsPartial && !$this->isNew(); if (null === $this->collGroupI18ns || null !== $criteria || $partial) { @@ -2177,10 +2289,11 @@ abstract class BaseGroup extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getGroupI18ns()); } - $query = GroupI18nQuery::create(null, $criteria); + + $query = ChildGroupI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2194,13 +2307,13 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * Method called to associate a GroupI18n object to this object - * through the GroupI18n foreign key attribute. + * Method called to associate a ChildGroupI18n object to this object + * through the ChildGroupI18n foreign key attribute. * - * @param GroupI18n $l GroupI18n - * @return Group The current object (for fluent API support) + * @param ChildGroupI18n $l ChildGroupI18n + * @return \Thelia\Model\Group The current object (for fluent API support) */ - public function addGroupI18n(GroupI18n $l) + public function addGroupI18n(ChildGroupI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -2210,6 +2323,7 @@ abstract class BaseGroup extends BaseObject implements Persistent $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); } @@ -2218,7 +2332,7 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * @param GroupI18n $groupI18n The groupI18n object to add. + * @param GroupI18n $groupI18n The groupI18n object to add. */ protected function doAddGroupI18n($groupI18n) { @@ -2227,8 +2341,8 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * @param GroupI18n $groupI18n The groupI18n object to remove. - * @return Group The current object (for fluent API support) + * @param GroupI18n $groupI18n The groupI18n object to remove. + * @return ChildGroup The current object (for fluent API support) */ public function removeGroupI18n($groupI18n) { @@ -2251,15 +2365,13 @@ abstract class BaseGroup extends BaseObject implements Persistent * This 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) + * @return void * @see addAdmins() */ public function clearAdmins() { - $this->collAdmins = null; // important to set this to null since that means it is uninitialized + $this->collAdmins = null; // important to set this to NULL since that means it is uninitialized $this->collAdminsPartial = null; - - return $this; } /** @@ -2273,33 +2385,33 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function initAdmins() { - $this->collAdmins = new PropelObjectCollection(); - $this->collAdmins->setModel('Admin'); + $this->collAdmins = new ObjectCollection(); + $this->collAdmins->setModel('\Thelia\Model\Admin'); } /** - * Gets a collection of Admin objects related by a many-to-many relationship + * Gets a collection of ChildAdmin 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 + * If this ChildGroup 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Admin[] List of Admin objects + * @return ObjectCollection|ChildAdmin[] List of ChildAdmin objects */ - public function getAdmins($criteria = null, PropelPDO $con = null) + public function getAdmins($criteria = null, ConnectionInterface $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) + $collAdmins = ChildAdminQuery::create(null, $criteria) ->filterByGroup($this) ->find($con); if (null !== $criteria) { @@ -2318,11 +2430,11 @@ abstract class BaseGroup extends BaseObject implements Persistent * It will 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) + * @param Collection $admins A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildGroup The current object (for fluent API support) */ - public function setAdmins(PropelCollection $admins, PropelPDO $con = null) + public function setAdmins(Collection $admins, ConnectionInterface $con = null) { $this->clearAdmins(); $currentAdmins = $this->getAdmins(); @@ -2341,22 +2453,22 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * Gets the number of Admin objects related by a many-to-many relationship + * Gets the number of ChildAdmin 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Admin objects + * @return int the number of related ChildAdmin objects */ - public function countAdmins($criteria = null, $distinct = false, PropelPDO $con = null) + public function countAdmins($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collAdmins || null !== $criteria) { if ($this->isNew() && null === $this->collAdmins) { return 0; } else { - $query = AdminQuery::create(null, $criteria); + $query = ChildAdminQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2371,52 +2483,60 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * Associate a Admin object to this object + * Associate a ChildAdmin 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) + * @param ChildAdmin $admin The ChildAdminGroup object to relate + * @return ChildGroup The current object (for fluent API support) */ - public function addAdmin(Admin $admin) + public function addAdmin(ChildAdmin $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; + $this->collAdmins[] = $admin; } return $this; } /** - * @param Admin $admin The admin object to add. + * @param Admin $admin The admin object to add. */ protected function doAddAdmin($admin) { - $adminGroup = new AdminGroup(); + $adminGroup = new ChildAdminGroup(); $adminGroup->setAdmin($admin); $this->addAdminGroup($adminGroup); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$admin->getGroups()->contains($this)) { + $foreignCollection = $admin->getGroups(); + $foreignCollection[] = $this; + } } /** - * Remove a Admin object to this object + * Remove a ChildAdmin 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) + * @param ChildAdmin $admin The ChildAdminGroup object to relate + * @return ChildGroup The current object (for fluent API support) */ - public function removeAdmin(Admin $admin) + public function removeAdmin(ChildAdmin $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; + + $this->adminsScheduledForDeletion[] = $admin; } return $this; @@ -2428,15 +2548,13 @@ abstract class BaseGroup extends BaseObject implements Persistent * This 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) + * @return void * @see addResources() */ public function clearResources() { - $this->collResources = null; // important to set this to null since that means it is uninitialized + $this->collResources = null; // important to set this to NULL since that means it is uninitialized $this->collResourcesPartial = null; - - return $this; } /** @@ -2450,33 +2568,33 @@ abstract class BaseGroup extends BaseObject implements Persistent */ public function initResources() { - $this->collResources = new PropelObjectCollection(); - $this->collResources->setModel('Resource'); + $this->collResources = new ObjectCollection(); + $this->collResources->setModel('\Thelia\Model\Resource'); } /** - * Gets a collection of Resource objects related by a many-to-many relationship + * Gets a collection of ChildResource 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 + * If this ChildGroup 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Resource[] List of Resource objects + * @return ObjectCollection|ChildResource[] List of ChildResource objects */ - public function getResources($criteria = null, PropelPDO $con = null) + public function getResources($criteria = null, ConnectionInterface $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) + $collResources = ChildResourceQuery::create(null, $criteria) ->filterByGroup($this) ->find($con); if (null !== $criteria) { @@ -2495,11 +2613,11 @@ abstract class BaseGroup extends BaseObject implements Persistent * It will 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) + * @param Collection $resources A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildGroup The current object (for fluent API support) */ - public function setResources(PropelCollection $resources, PropelPDO $con = null) + public function setResources(Collection $resources, ConnectionInterface $con = null) { $this->clearResources(); $currentResources = $this->getResources(); @@ -2518,22 +2636,22 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * Gets the number of Resource objects related by a many-to-many relationship + * Gets the number of ChildResource 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Resource objects + * @return int the number of related ChildResource objects */ - public function countResources($criteria = null, $distinct = false, PropelPDO $con = null) + public function countResources($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collResources || null !== $criteria) { if ($this->isNew() && null === $this->collResources) { return 0; } else { - $query = ResourceQuery::create(null, $criteria); + $query = ChildResourceQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2548,52 +2666,60 @@ abstract class BaseGroup extends BaseObject implements Persistent } /** - * Associate a Resource object to this object + * Associate a ChildResource 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) + * @param ChildResource $resource The ChildGroupResource object to relate + * @return ChildGroup The current object (for fluent API support) */ - public function addResource(Resource $resource) + public function addResource(ChildResource $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; + $this->collResources[] = $resource; } return $this; } /** - * @param Resource $resource The resource object to add. + * @param Resource $resource The resource object to add. */ protected function doAddResource($resource) { - $groupResource = new GroupResource(); + $groupResource = new ChildGroupResource(); $groupResource->setResource($resource); $this->addGroupResource($groupResource); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$resource->getGroups()->contains($this)) { + $foreignCollection = $resource->getGroups(); + $foreignCollection[] = $this; + } } /** - * Remove a Resource object to this object + * Remove a ChildResource 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) + * @param ChildResource $resource The ChildGroupResource object to relate + * @return ChildGroup The current object (for fluent API support) */ - public function removeResource(Resource $resource) + public function removeResource(ChildResource $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; + + $this->resourcesScheduledForDeletion[] = $resource; } return $this; @@ -2609,8 +2735,6 @@ abstract class BaseGroup extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2622,14 +2746,13 @@ abstract class BaseGroup extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collAdminGroups) { foreach ($this->collAdminGroups as $o) { $o->clearAllReferences($deep); @@ -2660,58 +2783,46 @@ abstract class BaseGroup extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collAdminGroups instanceof PropelCollection) { + if ($this->collAdminGroups instanceof Collection) { $this->collAdminGroups->clearIterator(); } $this->collAdminGroups = null; - if ($this->collGroupResources instanceof PropelCollection) { + if ($this->collGroupResources instanceof Collection) { $this->collGroupResources->clearIterator(); } $this->collGroupResources = null; - if ($this->collGroupModules instanceof PropelCollection) { + if ($this->collGroupModules instanceof Collection) { $this->collGroupModules->clearIterator(); } $this->collGroupModules = null; - if ($this->collGroupI18ns instanceof PropelCollection) { + if ($this->collGroupI18ns instanceof Collection) { $this->collGroupI18ns->clearIterator(); } $this->collGroupI18ns = null; - if ($this->collAdmins instanceof PropelCollection) { + if ($this->collAdmins instanceof Collection) { $this->collAdmins->clearIterator(); } $this->collAdmins = null; - if ($this->collResources instanceof PropelCollection) { + if ($this->collResources instanceof Collection) { $this->collResources->clearIterator(); } $this->collResources = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(GroupTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2719,11 +2830,11 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * 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) + * @return ChildGroup The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = GroupPeer::UPDATED_AT; + $this->modifiedColumns[] = GroupTableMap::UPDATED_AT; return $this; } @@ -2735,9 +2846,9 @@ abstract class BaseGroup extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Group The current object (for fluent API support) + * @return ChildGroup The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2758,10 +2869,10 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return GroupI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildGroupI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collGroupI18ns) { @@ -2774,10 +2885,10 @@ abstract class BaseGroup extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new GroupI18n(); + $translation = new ChildGroupI18n(); $translation->setLocale($locale); } else { - $translation = GroupI18nQuery::create() + $translation = ChildGroupI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -2792,14 +2903,14 @@ abstract class BaseGroup extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Group The current object (for fluent API support) + * @return ChildGroup The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - GroupI18nQuery::create() + ChildGroupI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -2819,10 +2930,10 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return GroupI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildGroupI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -2831,7 +2942,7 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -2842,8 +2953,8 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\GroupI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2855,7 +2966,7 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -2866,8 +2977,8 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\GroupI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2879,7 +2990,7 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -2890,8 +3001,8 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\GroupI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2903,7 +3014,7 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -2914,8 +3025,8 @@ abstract class BaseGroup extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\GroupI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -2923,4 +3034,122 @@ abstract class BaseGroup extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/GroupI18n.php b/core/lib/Thelia/Model/Base/GroupI18n.php new file mode 100644 index 000000000..de90d8863 --- /dev/null +++ b/core/lib/Thelia/Model/Base/GroupI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\GroupI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another GroupI18n instance. If + * obj is an instance of GroupI18n, delegates to + * equals(GroupI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return GroupI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return GroupI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\GroupI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = GroupI18nTableMap::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 \Thelia\Model\GroupI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = GroupI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\GroupI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = GroupI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\GroupI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = GroupI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\GroupI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = GroupI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\GroupI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = GroupI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : GroupI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : GroupI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = GroupI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\GroupI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(GroupI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildGroupI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aGroup = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see GroupI18n::setDeleted() + * @see GroupI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildGroupI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); + } + + $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); + GroupI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(GroupI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(GroupI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(GroupI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(GroupI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(GroupI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(GroupI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = GroupI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['GroupI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['GroupI18n'][serialize($this->getPrimaryKey())] = true; + $keys = GroupI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = GroupI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = GroupI18nTableMap::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(GroupI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(GroupI18nTableMap::ID)) $criteria->add(GroupI18nTableMap::ID, $this->id); + if ($this->isColumnModified(GroupI18nTableMap::LOCALE)) $criteria->add(GroupI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(GroupI18nTableMap::TITLE)) $criteria->add(GroupI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(GroupI18nTableMap::DESCRIPTION)) $criteria->add(GroupI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(GroupI18nTableMap::CHAPO)) $criteria->add(GroupI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(GroupI18nTableMap::POSTSCRIPTUM)) $criteria->add(GroupI18nTableMap::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(GroupI18nTableMap::DATABASE_NAME); + $criteria->add(GroupI18nTableMap::ID, $this->id); + $criteria->add(GroupI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildGroup object. + * + * @param ChildGroup $v + * @return \Thelia\Model\GroupI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setGroup(ChildGroup $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 ChildGroup object, it will not be re-added. + if ($v !== null) { + $v->addGroupI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildGroup object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildGroup The associated ChildGroup object. + * @throws PropelException + */ + public function getGroup(ConnectionInterface $con = null) + { + if ($this->aGroup === null && ($this->id !== null)) { + $this->aGroup = ChildGroupQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aGroup = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(GroupI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseGroupI18nQuery.php b/core/lib/Thelia/Model/Base/GroupI18nQuery.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseGroupI18nQuery.php rename to core/lib/Thelia/Model/Base/GroupI18nQuery.php index f0d73813b..8dc7b44ec --- a/core/lib/Thelia/Model/om/BaseGroupI18nQuery.php +++ b/core/lib/Thelia/Model/Base/GroupI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return GroupI18n|GroupI18n[]|mixed the result, formatted by the current formatter + * @return ChildGroupI18n|array|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 + if ((null !== ($obj = GroupI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(GroupI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(GroupI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return GroupI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildGroupI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `group_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseGroupI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new GroupI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildGroupI18n(); $obj->hydrate($row); - GroupI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + GroupI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return GroupI18n|GroupI18n[]|mixed the result, formatted by the current formatter + * @return ChildGroupI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|GroupI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return GroupI18nQuery The current query, for fluid interface + * @return ChildGroupI18nQuery 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); + $this->addUsingAlias(GroupI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(GroupI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return GroupI18nQuery The current query, for fluid interface + * @return ChildGroupI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseGroupI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(GroupI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(GroupI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByGroup() @@ -270,18 +266,18 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * 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 + * @return ChildGroupI18nQuery 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); + $this->addUsingAlias(GroupI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(GroupI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(GroupI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * 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 + * @return ChildGroupI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(GroupI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * 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 + * @return ChildGroupI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(GroupI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * 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 + * @return ChildGroupI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(GroupI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * 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 + * @return ChildGroupI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(GroupI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * 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 + * @return ChildGroupI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseGroupI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(GroupI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Group object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Group|ObjectCollection $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. + * @return ChildGroupI18nQuery The current query, for fluid interface */ public function filterByGroup($group, $comparison = null) { - if ($group instanceof Group) { + if ($group instanceof \Thelia\Model\Group) { return $this - ->addUsingAlias(GroupI18nPeer::ID, $group->getId(), $comparison); - } elseif ($group instanceof PropelObjectCollection) { + ->addUsingAlias(GroupI18nTableMap::ID, $group->getId(), $comparison); + } elseif ($group instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(GroupI18nPeer::ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(GroupI18nTableMap::ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection'); + throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria * @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 + * @return ChildGroupI18nQuery The current query, for fluid interface */ public function joinGroup($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseGroupI18nQuery extends ModelCriteria /** * Use the Group relation Group object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseGroupI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param GroupI18n $groupI18n Object to remove from the list of results + * @param ChildGroupI18n $groupI18n Object to remove from the list of results * - * @return GroupI18nQuery The current query, for fluid interface + * @return ChildGroupI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(GroupI18nTableMap::ID), $groupI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(GroupI18nTableMap::LOCALE), $groupI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the group_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + GroupI18nTableMap::clearInstancePool(); + GroupI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildGroupI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildGroupI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(GroupI18nTableMap::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(); + + + GroupI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + GroupI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // GroupI18nQuery diff --git a/core/lib/Thelia/Model/Base/GroupModule.php b/core/lib/Thelia/Model/Base/GroupModule.php new file mode 100644 index 000000000..620ca9c91 --- /dev/null +++ b/core/lib/Thelia/Model/Base/GroupModule.php @@ -0,0 +1,1572 @@ +access = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\GroupModule object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another GroupModule instance. If + * obj is an instance of GroupModule, delegates to + * equals(GroupModule). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return GroupModule The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return GroupModule The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\GroupModule The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = GroupModuleTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [group_id] column. + * + * @param int $v new value + * @return \Thelia\Model\GroupModule The current object (for fluent API support) + */ + public function setGroupId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->group_id !== $v) { + $this->group_id = $v; + $this->modifiedColumns[] = GroupModuleTableMap::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 \Thelia\Model\GroupModule The current object (for fluent API support) + */ + public function setModuleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->module_id !== $v) { + $this->module_id = $v; + $this->modifiedColumns[] = GroupModuleTableMap::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 \Thelia\Model\GroupModule The current object (for fluent API support) + */ + public function setAccess($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->access !== $v) { + $this->access = $v; + $this->modifiedColumns[] = GroupModuleTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = GroupModuleTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = GroupModuleTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupModuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupModuleTableMap::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->group_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupModuleTableMap::translateFieldName('ModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->module_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupModuleTableMap::translateFieldName('Access', TableMap::TYPE_PHPNAME, $indexType)]; + $this->access = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : GroupModuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : GroupModuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = GroupModuleTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\GroupModule object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(GroupModuleTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildGroupModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see GroupModule::setDeleted() + * @see GroupModule::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildGroupModuleQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(GroupModuleTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + GroupModuleTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = GroupModuleTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupModuleTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(GroupModuleTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(GroupModuleTableMap::GROUP_ID)) { + $modifiedColumns[':p' . $index++] = 'GROUP_ID'; + } + if ($this->isColumnModified(GroupModuleTableMap::MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'MODULE_ID'; + } + if ($this->isColumnModified(GroupModuleTableMap::ACCESS)) { + $modifiedColumns[':p' . $index++] = 'ACCESS'; + } + if ($this->isColumnModified(GroupModuleTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(GroupModuleTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = GroupModuleTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()] = true; + $keys = GroupModuleTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = GroupModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = GroupModuleTableMap::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(GroupModuleTableMap::DATABASE_NAME); + + if ($this->isColumnModified(GroupModuleTableMap::ID)) $criteria->add(GroupModuleTableMap::ID, $this->id); + if ($this->isColumnModified(GroupModuleTableMap::GROUP_ID)) $criteria->add(GroupModuleTableMap::GROUP_ID, $this->group_id); + if ($this->isColumnModified(GroupModuleTableMap::MODULE_ID)) $criteria->add(GroupModuleTableMap::MODULE_ID, $this->module_id); + if ($this->isColumnModified(GroupModuleTableMap::ACCESS)) $criteria->add(GroupModuleTableMap::ACCESS, $this->access); + if ($this->isColumnModified(GroupModuleTableMap::CREATED_AT)) $criteria->add(GroupModuleTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) $criteria->add(GroupModuleTableMap::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(GroupModuleTableMap::DATABASE_NAME); + $criteria->add(GroupModuleTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildGroup object. + * + * @param ChildGroup $v + * @return \Thelia\Model\GroupModule The current object (for fluent API support) + * @throws PropelException + */ + public function setGroup(ChildGroup $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 ChildGroup object, it will not be re-added. + if ($v !== null) { + $v->addGroupModule($this); + } + + + return $this; + } + + + /** + * Get the associated ChildGroup object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildGroup The associated ChildGroup object. + * @throws PropelException + */ + public function getGroup(ConnectionInterface $con = null) + { + if ($this->aGroup === null && ($this->group_id !== null)) { + $this->aGroup = ChildGroupQuery::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 ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\GroupModule The current object (for fluent API support) + * @throws PropelException + */ + public function setModule(ChildModule $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 ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addGroupModule($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModule(ConnectionInterface $con = null) + { + if ($this->aModule === null && ($this->module_id !== null)) { + $this->aModule = ChildModuleQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aGroup = null; + $this->aModule = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(GroupModuleTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildGroupModule The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = GroupModuleTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php b/core/lib/Thelia/Model/Base/GroupModuleQuery.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseGroupModuleQuery.php rename to core/lib/Thelia/Model/Base/GroupModuleQuery.php index 4a0b7b0d1..531342ec9 --- a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php +++ b/core/lib/Thelia/Model/Base/GroupModuleQuery.php @@ -1,100 +1,99 @@ setModelAlias($modelAlias); } @@ -115,21 +114,21 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return GroupModule|GroupModule[]|mixed the result, formatted by the current formatter + * @return ChildGroupModule|array|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 + if ((null !== ($obj = GroupModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(GroupModuleTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -141,46 +140,31 @@ abstract class BaseGroupModuleQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return GroupModule A model object, or null if the key is not found - * @throws PropelException + * @return ChildGroupModule A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `group_id`, `module_id`, `access`, `created_at`, `updated_at` FROM `group_module` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new GroupModule(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildGroupModule(); $obj->hydrate($row); - GroupModulePeer::addInstanceToPool($obj, (string) $key); + GroupModuleTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -191,19 +175,19 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return GroupModule|GroupModule[]|mixed the result, formatted by the current formatter + * @return ChildGroupModule|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -212,22 +196,22 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|GroupModule[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -235,12 +219,12 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return GroupModuleQuery The current query, for fluid interface + * @return ChildGroupModuleQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(GroupModulePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(GroupModuleTableMap::ID, $key, Criteria::EQUAL); } /** @@ -248,12 +232,12 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return GroupModuleQuery The current query, for fluid interface + * @return ChildGroupModuleQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(GroupModulePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(GroupModuleTableMap::ID, $keys, Criteria::IN); } /** @@ -263,8 +247,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -273,18 +256,18 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * 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 + * @return ChildGroupModuleQuery 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); + $this->addUsingAlias(GroupModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(GroupModulePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -295,7 +278,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupModulePeer::ID, $id, $comparison); + return $this->addUsingAlias(GroupModuleTableMap::ID, $id, $comparison); } /** @@ -305,8 +288,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * $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 + * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12 * * * @see filterByGroup() @@ -317,18 +299,18 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * 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 + * @return ChildGroupModuleQuery 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); + $this->addUsingAlias(GroupModuleTableMap::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($groupId['max'])) { - $this->addUsingAlias(GroupModulePeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupModuleTableMap::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -339,7 +321,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupModulePeer::GROUP_ID, $groupId, $comparison); + return $this->addUsingAlias(GroupModuleTableMap::GROUP_ID, $groupId, $comparison); } /** @@ -349,8 +331,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * $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 + * $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12 * * * @see filterByModule() @@ -361,18 +342,18 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * 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 + * @return ChildGroupModuleQuery 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); + $this->addUsingAlias(GroupModuleTableMap::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($moduleId['max'])) { - $this->addUsingAlias(GroupModulePeer::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupModuleTableMap::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -383,7 +364,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupModulePeer::MODULE_ID, $moduleId, $comparison); + return $this->addUsingAlias(GroupModuleTableMap::MODULE_ID, $moduleId, $comparison); } /** @@ -393,8 +374,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * $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 + * $query->filterByAccess(array('min' => 12)); // WHERE access > 12 * * * @param mixed $access The value to use as filter. @@ -403,18 +383,18 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * 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 + * @return ChildGroupModuleQuery 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); + $this->addUsingAlias(GroupModuleTableMap::ACCESS, $access['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($access['max'])) { - $this->addUsingAlias(GroupModulePeer::ACCESS, $access['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupModuleTableMap::ACCESS, $access['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -425,7 +405,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupModulePeer::ACCESS, $access, $comparison); + return $this->addUsingAlias(GroupModuleTableMap::ACCESS, $access, $comparison); } /** @@ -446,18 +426,18 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * 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 + * @return ChildGroupModuleQuery 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); + $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(GroupModulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -468,7 +448,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupModulePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -489,18 +469,18 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * 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 + * @return ChildGroupModuleQuery 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); + $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(GroupModulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -511,32 +491,31 @@ abstract class BaseGroupModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupModulePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Group object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Group|ObjectCollection $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. + * @return ChildGroupModuleQuery The current query, for fluid interface */ public function filterByGroup($group, $comparison = null) { - if ($group instanceof Group) { + if ($group instanceof \Thelia\Model\Group) { return $this - ->addUsingAlias(GroupModulePeer::GROUP_ID, $group->getId(), $comparison); - } elseif ($group instanceof PropelObjectCollection) { + ->addUsingAlias(GroupModuleTableMap::GROUP_ID, $group->getId(), $comparison); + } elseif ($group instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(GroupModulePeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(GroupModuleTableMap::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection'); + throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection'); } } @@ -546,7 +525,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * @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 + * @return ChildGroupModuleQuery The current query, for fluid interface */ public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -575,7 +554,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria /** * Use the Group relation Group object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -591,28 +570,27 @@ abstract class BaseGroupModuleQuery extends ModelCriteria } /** - * Filter the query by a related Module object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Module|ObjectCollection $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. + * @return ChildGroupModuleQuery The current query, for fluid interface */ public function filterByModule($module, $comparison = null) { - if ($module instanceof Module) { + if ($module instanceof \Thelia\Model\Module) { return $this - ->addUsingAlias(GroupModulePeer::MODULE_ID, $module->getId(), $comparison); - } elseif ($module instanceof PropelObjectCollection) { + ->addUsingAlias(GroupModuleTableMap::MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(GroupModulePeer::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(GroupModuleTableMap::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByModule() only accepts arguments of type Module or PropelCollection'); + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); } } @@ -622,7 +600,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * @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 + * @return ChildGroupModuleQuery The current query, for fluid interface */ public function joinModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -651,7 +629,7 @@ abstract class BaseGroupModuleQuery extends ModelCriteria /** * Use the Module relation Module object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -669,19 +647,94 @@ abstract class BaseGroupModuleQuery extends ModelCriteria /** * Exclude object from result * - * @param GroupModule $groupModule Object to remove from the list of results + * @param ChildGroupModule $groupModule Object to remove from the list of results * - * @return GroupModuleQuery The current query, for fluid interface + * @return ChildGroupModuleQuery The current query, for fluid interface */ public function prune($groupModule = null) { if ($groupModule) { - $this->addUsingAlias(GroupModulePeer::ID, $groupModule->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(GroupModuleTableMap::ID, $groupModule->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the group_module table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + GroupModuleTableMap::clearInstancePool(); + GroupModuleTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildGroupModule or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildGroupModule object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(GroupModuleTableMap::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(); + + + GroupModuleTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + GroupModuleTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -689,31 +742,11 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return GroupModuleQuery The current query, for fluid interface + * @return ChildGroupModuleQuery 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); + return $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -721,30 +754,51 @@ abstract class BaseGroupModuleQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return GroupModuleQuery The current query, for fluid interface + * @return ChildGroupModuleQuery 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); + return $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildGroupModuleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(GroupModuleTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildGroupModuleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(GroupModuleTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return GroupModuleQuery The current query, for fluid interface + * @return ChildGroupModuleQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(GroupModulePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(GroupModuleTableMap::CREATED_AT); } /** * Order by create date asc * - * @return GroupModuleQuery The current query, for fluid interface + * @return ChildGroupModuleQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(GroupModulePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(GroupModuleTableMap::CREATED_AT); } -} + +} // GroupModuleQuery diff --git a/core/lib/Thelia/Model/om/BaseGroupQuery.php b/core/lib/Thelia/Model/Base/GroupQuery.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseGroupQuery.php rename to core/lib/Thelia/Model/Base/GroupQuery.php index 5c9695e10..8ca963848 --- a/core/lib/Thelia/Model/om/BaseGroupQuery.php +++ b/core/lib/Thelia/Model/Base/GroupQuery.php @@ -1,104 +1,100 @@ setModelAlias($modelAlias); } @@ -119,21 +115,21 @@ abstract class BaseGroupQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Group|Group[]|mixed the result, formatted by the current formatter + * @return ChildGroup|array|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 + if ((null !== ($obj = GroupTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(GroupTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -145,46 +141,31 @@ abstract class BaseGroupQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Group A model object, or null if the key is not found - * @throws PropelException + * @return ChildGroup A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `group` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Group(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildGroup(); $obj->hydrate($row); - GroupPeer::addInstanceToPool($obj, (string) $key); + GroupTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -195,19 +176,19 @@ abstract class BaseGroupQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Group|Group[]|mixed the result, formatted by the current formatter + * @return ChildGroup|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -216,22 +197,22 @@ abstract class BaseGroupQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Group[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -239,12 +220,12 @@ abstract class BaseGroupQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return GroupQuery The current query, for fluid interface + * @return ChildGroupQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(GroupPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(GroupTableMap::ID, $key, Criteria::EQUAL); } /** @@ -252,12 +233,12 @@ abstract class BaseGroupQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return GroupQuery The current query, for fluid interface + * @return ChildGroupQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(GroupPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(GroupTableMap::ID, $keys, Criteria::IN); } /** @@ -267,8 +248,7 @@ abstract class BaseGroupQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -277,18 +257,18 @@ abstract class BaseGroupQuery extends ModelCriteria * 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 + * @return ChildGroupQuery 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); + $this->addUsingAlias(GroupTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(GroupPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -299,7 +279,7 @@ abstract class BaseGroupQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupPeer::ID, $id, $comparison); + return $this->addUsingAlias(GroupTableMap::ID, $id, $comparison); } /** @@ -315,7 +295,7 @@ abstract class BaseGroupQuery extends ModelCriteria * 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 + * @return ChildGroupQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -328,7 +308,7 @@ abstract class BaseGroupQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupPeer::CODE, $code, $comparison); + return $this->addUsingAlias(GroupTableMap::CODE, $code, $comparison); } /** @@ -349,18 +329,18 @@ abstract class BaseGroupQuery extends ModelCriteria * 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 + * @return ChildGroupQuery 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); + $this->addUsingAlias(GroupTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(GroupPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -371,7 +351,7 @@ abstract class BaseGroupQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(GroupTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -392,18 +372,18 @@ abstract class BaseGroupQuery extends ModelCriteria * 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 + * @return ChildGroupQuery 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); + $this->addUsingAlias(GroupTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(GroupPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -414,30 +394,29 @@ abstract class BaseGroupQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(GroupTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related AdminGroup object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\AdminGroup|ObjectCollection $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. + * @return ChildGroupQuery The current query, for fluid interface */ public function filterByAdminGroup($adminGroup, $comparison = null) { - if ($adminGroup instanceof AdminGroup) { + if ($adminGroup instanceof \Thelia\Model\AdminGroup) { return $this - ->addUsingAlias(GroupPeer::ID, $adminGroup->getGroupId(), $comparison); - } elseif ($adminGroup instanceof PropelObjectCollection) { + ->addUsingAlias(GroupTableMap::ID, $adminGroup->getGroupId(), $comparison); + } elseif ($adminGroup instanceof ObjectCollection) { return $this ->useAdminGroupQuery() ->filterByPrimaryKeys($adminGroup->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection'); + throw new PropelException('filterByAdminGroup() only accepts arguments of type \Thelia\Model\AdminGroup or Collection'); } } @@ -447,7 +426,7 @@ abstract class BaseGroupQuery extends ModelCriteria * @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 + * @return ChildGroupQuery The current query, for fluid interface */ public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -476,7 +455,7 @@ abstract class BaseGroupQuery extends ModelCriteria /** * Use the AdminGroup relation AdminGroup object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -492,26 +471,25 @@ abstract class BaseGroupQuery extends ModelCriteria } /** - * Filter the query by a related GroupResource object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\GroupResource|ObjectCollection $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. + * @return ChildGroupQuery The current query, for fluid interface */ public function filterByGroupResource($groupResource, $comparison = null) { - if ($groupResource instanceof GroupResource) { + if ($groupResource instanceof \Thelia\Model\GroupResource) { return $this - ->addUsingAlias(GroupPeer::ID, $groupResource->getGroupId(), $comparison); - } elseif ($groupResource instanceof PropelObjectCollection) { + ->addUsingAlias(GroupTableMap::ID, $groupResource->getGroupId(), $comparison); + } elseif ($groupResource instanceof ObjectCollection) { return $this ->useGroupResourceQuery() ->filterByPrimaryKeys($groupResource->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection'); + throw new PropelException('filterByGroupResource() only accepts arguments of type \Thelia\Model\GroupResource or Collection'); } } @@ -521,7 +499,7 @@ abstract class BaseGroupQuery extends ModelCriteria * @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 + * @return ChildGroupQuery The current query, for fluid interface */ public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -550,7 +528,7 @@ abstract class BaseGroupQuery extends ModelCriteria /** * Use the GroupResource relation GroupResource object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -566,26 +544,25 @@ abstract class BaseGroupQuery extends ModelCriteria } /** - * Filter the query by a related GroupModule object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\GroupModule|ObjectCollection $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. + * @return ChildGroupQuery The current query, for fluid interface */ public function filterByGroupModule($groupModule, $comparison = null) { - if ($groupModule instanceof GroupModule) { + if ($groupModule instanceof \Thelia\Model\GroupModule) { return $this - ->addUsingAlias(GroupPeer::ID, $groupModule->getGroupId(), $comparison); - } elseif ($groupModule instanceof PropelObjectCollection) { + ->addUsingAlias(GroupTableMap::ID, $groupModule->getGroupId(), $comparison); + } elseif ($groupModule instanceof ObjectCollection) { return $this ->useGroupModuleQuery() ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection'); + throw new PropelException('filterByGroupModule() only accepts arguments of type \Thelia\Model\GroupModule or Collection'); } } @@ -595,7 +572,7 @@ abstract class BaseGroupQuery extends ModelCriteria * @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 + * @return ChildGroupQuery The current query, for fluid interface */ public function joinGroupModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -624,7 +601,7 @@ abstract class BaseGroupQuery extends ModelCriteria /** * Use the GroupModule relation GroupModule object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -640,26 +617,25 @@ abstract class BaseGroupQuery extends ModelCriteria } /** - * Filter the query by a related GroupI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\GroupI18n|ObjectCollection $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. + * @return ChildGroupQuery The current query, for fluid interface */ public function filterByGroupI18n($groupI18n, $comparison = null) { - if ($groupI18n instanceof GroupI18n) { + if ($groupI18n instanceof \Thelia\Model\GroupI18n) { return $this - ->addUsingAlias(GroupPeer::ID, $groupI18n->getId(), $comparison); - } elseif ($groupI18n instanceof PropelObjectCollection) { + ->addUsingAlias(GroupTableMap::ID, $groupI18n->getId(), $comparison); + } elseif ($groupI18n instanceof ObjectCollection) { return $this ->useGroupI18nQuery() ->filterByPrimaryKeys($groupI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByGroupI18n() only accepts arguments of type GroupI18n or PropelCollection'); + throw new PropelException('filterByGroupI18n() only accepts arguments of type \Thelia\Model\GroupI18n or Collection'); } } @@ -669,7 +645,7 @@ abstract class BaseGroupQuery extends ModelCriteria * @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 + * @return ChildGroupQuery The current query, for fluid interface */ public function joinGroupI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -698,7 +674,7 @@ abstract class BaseGroupQuery extends ModelCriteria /** * Use the GroupI18n relation GroupI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -717,10 +693,10 @@ abstract class BaseGroupQuery extends ModelCriteria * 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 + * @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 + * @return ChildGroupQuery The current query, for fluid interface */ public function filterByAdmin($admin, $comparison = Criteria::EQUAL) { @@ -734,10 +710,10 @@ abstract class BaseGroupQuery extends ModelCriteria * 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 + * @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 + * @return ChildGroupQuery The current query, for fluid interface */ public function filterByResource($resource, $comparison = Criteria::EQUAL) { @@ -750,19 +726,94 @@ abstract class BaseGroupQuery extends ModelCriteria /** * Exclude object from result * - * @param Group $group Object to remove from the list of results + * @param ChildGroup $group Object to remove from the list of results * - * @return GroupQuery The current query, for fluid interface + * @return ChildGroupQuery The current query, for fluid interface */ public function prune($group = null) { if ($group) { - $this->addUsingAlias(GroupPeer::ID, $group->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(GroupTableMap::ID, $group->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the group table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + GroupTableMap::clearInstancePool(); + GroupTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildGroup or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildGroup object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(GroupTableMap::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(); + + + GroupTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + GroupTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -770,31 +821,11 @@ abstract class BaseGroupQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return GroupQuery The current query, for fluid interface + * @return ChildGroupQuery 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); + return $this->addUsingAlias(GroupTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -802,32 +833,53 @@ abstract class BaseGroupQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return GroupQuery The current query, for fluid interface + * @return ChildGroupQuery 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); + return $this->addUsingAlias(GroupTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildGroupQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(GroupTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildGroupQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(GroupTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return GroupQuery The current query, for fluid interface + * @return ChildGroupQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(GroupPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(GroupTableMap::CREATED_AT); } /** * Order by create date asc * - * @return GroupQuery The current query, for fluid interface + * @return ChildGroupQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(GroupPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(GroupTableMap::CREATED_AT); } + // i18n behavior /** @@ -837,9 +889,9 @@ abstract class BaseGroupQuery extends ModelCriteria * @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 + * @return ChildGroupQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'GroupI18n'; @@ -855,9 +907,9 @@ abstract class BaseGroupQuery extends ModelCriteria * @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 + * @return ChildGroupQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -876,13 +928,13 @@ abstract class BaseGroupQuery extends ModelCriteria * @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 + * @return ChildGroupI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupI18n', 'Thelia\Model\GroupI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'GroupI18n', '\Thelia\Model\GroupI18nQuery'); } -} +} // GroupQuery diff --git a/core/lib/Thelia/Model/Base/GroupResource.php b/core/lib/Thelia/Model/Base/GroupResource.php new file mode 100644 index 000000000..84d6006b0 --- /dev/null +++ b/core/lib/Thelia/Model/Base/GroupResource.php @@ -0,0 +1,1646 @@ +read = 0; + $this->write = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\GroupResource object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another GroupResource instance. If + * obj is an instance of GroupResource, delegates to + * equals(GroupResource). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return GroupResource The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return GroupResource The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\GroupResource The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = GroupResourceTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [group_id] column. + * + * @param int $v new value + * @return \Thelia\Model\GroupResource The current object (for fluent API support) + */ + public function setGroupId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->group_id !== $v) { + $this->group_id = $v; + $this->modifiedColumns[] = GroupResourceTableMap::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 \Thelia\Model\GroupResource The current object (for fluent API support) + */ + public function setResourceId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->resource_id !== $v) { + $this->resource_id = $v; + $this->modifiedColumns[] = GroupResourceTableMap::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 \Thelia\Model\GroupResource The current object (for fluent API support) + */ + public function setRead($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->read !== $v) { + $this->read = $v; + $this->modifiedColumns[] = GroupResourceTableMap::READ; + } + + + return $this; + } // setRead() + + /** + * Set the value of [write] column. + * + * @param int $v new value + * @return \Thelia\Model\GroupResource The current object (for fluent API support) + */ + public function setWrite($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->write !== $v) { + $this->write = $v; + $this->modifiedColumns[] = GroupResourceTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = GroupResourceTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = GroupResourceTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupResourceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupResourceTableMap::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->group_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupResourceTableMap::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->resource_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupResourceTableMap::translateFieldName('Read', TableMap::TYPE_PHPNAME, $indexType)]; + $this->read = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : GroupResourceTableMap::translateFieldName('Write', TableMap::TYPE_PHPNAME, $indexType)]; + $this->write = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : GroupResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : GroupResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = GroupResourceTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\GroupResource object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(GroupResourceTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildGroupResourceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see GroupResource::setDeleted() + * @see GroupResource::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildGroupResourceQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(GroupResourceTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + GroupResourceTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = GroupResourceTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupResourceTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(GroupResourceTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(GroupResourceTableMap::GROUP_ID)) { + $modifiedColumns[':p' . $index++] = 'GROUP_ID'; + } + if ($this->isColumnModified(GroupResourceTableMap::RESOURCE_ID)) { + $modifiedColumns[':p' . $index++] = 'RESOURCE_ID'; + } + if ($this->isColumnModified(GroupResourceTableMap::READ)) { + $modifiedColumns[':p' . $index++] = 'READ'; + } + if ($this->isColumnModified(GroupResourceTableMap::WRITE)) { + $modifiedColumns[':p' . $index++] = 'WRITE'; + } + if ($this->isColumnModified(GroupResourceTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(GroupResourceTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = GroupResourceTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['GroupResource'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['GroupResource'][serialize($this->getPrimaryKey())] = true; + $keys = GroupResourceTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = GroupResourceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = GroupResourceTableMap::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(GroupResourceTableMap::DATABASE_NAME); + + if ($this->isColumnModified(GroupResourceTableMap::ID)) $criteria->add(GroupResourceTableMap::ID, $this->id); + if ($this->isColumnModified(GroupResourceTableMap::GROUP_ID)) $criteria->add(GroupResourceTableMap::GROUP_ID, $this->group_id); + if ($this->isColumnModified(GroupResourceTableMap::RESOURCE_ID)) $criteria->add(GroupResourceTableMap::RESOURCE_ID, $this->resource_id); + if ($this->isColumnModified(GroupResourceTableMap::READ)) $criteria->add(GroupResourceTableMap::READ, $this->read); + if ($this->isColumnModified(GroupResourceTableMap::WRITE)) $criteria->add(GroupResourceTableMap::WRITE, $this->write); + if ($this->isColumnModified(GroupResourceTableMap::CREATED_AT)) $criteria->add(GroupResourceTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) $criteria->add(GroupResourceTableMap::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(GroupResourceTableMap::DATABASE_NAME); + $criteria->add(GroupResourceTableMap::ID, $this->id); + $criteria->add(GroupResourceTableMap::GROUP_ID, $this->group_id); + $criteria->add(GroupResourceTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildGroup object. + * + * @param ChildGroup $v + * @return \Thelia\Model\GroupResource The current object (for fluent API support) + * @throws PropelException + */ + public function setGroup(ChildGroup $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 ChildGroup object, it will not be re-added. + if ($v !== null) { + $v->addGroupResource($this); + } + + + return $this; + } + + + /** + * Get the associated ChildGroup object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildGroup The associated ChildGroup object. + * @throws PropelException + */ + public function getGroup(ConnectionInterface $con = null) + { + if ($this->aGroup === null && ($this->group_id !== null)) { + $this->aGroup = ChildGroupQuery::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 ChildResource object. + * + * @param ChildResource $v + * @return \Thelia\Model\GroupResource The current object (for fluent API support) + * @throws PropelException + */ + public function setResource(ChildResource $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 ChildResource object, it will not be re-added. + if ($v !== null) { + $v->addGroupResource($this); + } + + + return $this; + } + + + /** + * Get the associated ChildResource object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildResource The associated ChildResource object. + * @throws PropelException + */ + public function getResource(ConnectionInterface $con = null) + { + if ($this->aResource === null && ($this->resource_id !== null)) { + $this->aResource = ChildResourceQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aGroup = null; + $this->aResource = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(GroupResourceTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildGroupResource The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = GroupResourceTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php b/core/lib/Thelia/Model/Base/GroupResourceQuery.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseGroupResourceQuery.php rename to core/lib/Thelia/Model/Base/GroupResourceQuery.php index d6ff84c8b..e57894707 --- a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php +++ b/core/lib/Thelia/Model/Base/GroupResourceQuery.php @@ -1,105 +1,103 @@ setModelAlias($modelAlias); } @@ -119,23 +117,22 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * $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 + * @param array[$id, $group_id, $resource_id] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return GroupResource|GroupResource[]|mixed the result, formatted by the current formatter + * @return ChildGroupResource|array|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 + if ((null !== ($obj = GroupResourceTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(GroupResourceTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -152,14 +149,13 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return GroupResource A model object, or null if the key is not found - * @throws PropelException + * @return ChildGroupResource A model object, or null if the key is not found */ 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'; + $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); @@ -168,13 +164,13 @@ abstract class BaseGroupResourceQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new GroupResource(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildGroupResource(); $obj->hydrate($row); - GroupResourcePeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); + GroupResourceTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); } $stmt->closeCursor(); @@ -185,19 +181,19 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return GroupResource|GroupResource[]|mixed the result, formatted by the current formatter + * @return ChildGroupResource|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -206,22 +202,22 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|GroupResource[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -229,13 +225,13 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return GroupResourceQuery The current query, for fluid interface + * @return ChildGroupResourceQuery 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); + $this->addUsingAlias(GroupResourceTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $key[1], Criteria::EQUAL); + $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $key[2], Criteria::EQUAL); return $this; } @@ -245,7 +241,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return GroupResourceQuery The current query, for fluid interface + * @return ChildGroupResourceQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -253,10 +249,10 @@ abstract class BaseGroupResourceQuery extends ModelCriteria 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 = $this->getNewCriterion(GroupResourceTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(GroupResourceTableMap::GROUP_ID, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); - $cton2 = $this->getNewCriterion(GroupResourcePeer::RESOURCE_ID, $key[2], Criteria::EQUAL); + $cton2 = $this->getNewCriterion(GroupResourceTableMap::RESOURCE_ID, $key[2], Criteria::EQUAL); $cton0->addAnd($cton2); $this->addOr($cton0); } @@ -271,8 +267,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -281,18 +276,18 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * 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 + * @return ChildGroupResourceQuery 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); + $this->addUsingAlias(GroupResourceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(GroupResourcePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupResourceTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -303,7 +298,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupResourcePeer::ID, $id, $comparison); + return $this->addUsingAlias(GroupResourceTableMap::ID, $id, $comparison); } /** @@ -313,8 +308,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $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 + * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12 * * * @see filterByGroup() @@ -325,18 +319,18 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * 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 + * @return ChildGroupResourceQuery 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); + $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($groupId['max'])) { - $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -347,7 +341,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId, $comparison); + return $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $groupId, $comparison); } /** @@ -357,8 +351,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $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 + * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12 * * * @see filterByResource() @@ -369,18 +362,18 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * 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 + * @return ChildGroupResourceQuery 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); + $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resourceId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($resourceId['max'])) { - $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resourceId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -391,7 +384,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId, $comparison); + return $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resourceId, $comparison); } /** @@ -401,8 +394,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $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 + * $query->filterByRead(array('min' => 12)); // WHERE read > 12 * * * @param mixed $read The value to use as filter. @@ -411,18 +403,18 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * 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 + * @return ChildGroupResourceQuery 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); + $this->addUsingAlias(GroupResourceTableMap::READ, $read['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($read['max'])) { - $this->addUsingAlias(GroupResourcePeer::READ, $read['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupResourceTableMap::READ, $read['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -433,7 +425,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupResourcePeer::READ, $read, $comparison); + return $this->addUsingAlias(GroupResourceTableMap::READ, $read, $comparison); } /** @@ -443,8 +435,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * $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 + * $query->filterByWrite(array('min' => 12)); // WHERE write > 12 * * * @param mixed $write The value to use as filter. @@ -453,18 +444,18 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * 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 + * @return ChildGroupResourceQuery 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); + $this->addUsingAlias(GroupResourceTableMap::WRITE, $write['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($write['max'])) { - $this->addUsingAlias(GroupResourcePeer::WRITE, $write['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupResourceTableMap::WRITE, $write['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -475,7 +466,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupResourcePeer::WRITE, $write, $comparison); + return $this->addUsingAlias(GroupResourceTableMap::WRITE, $write, $comparison); } /** @@ -496,18 +487,18 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * 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 + * @return ChildGroupResourceQuery 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); + $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -518,7 +509,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -539,18 +530,18 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * 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 + * @return ChildGroupResourceQuery 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); + $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -561,32 +552,31 @@ abstract class BaseGroupResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Group object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Group|ObjectCollection $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. + * @return ChildGroupResourceQuery The current query, for fluid interface */ public function filterByGroup($group, $comparison = null) { - if ($group instanceof Group) { + if ($group instanceof \Thelia\Model\Group) { return $this - ->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->getId(), $comparison); - } elseif ($group instanceof PropelObjectCollection) { + ->addUsingAlias(GroupResourceTableMap::GROUP_ID, $group->getId(), $comparison); + } elseif ($group instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(GroupResourceTableMap::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection'); + throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection'); } } @@ -596,7 +586,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * @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 + * @return ChildGroupResourceQuery The current query, for fluid interface */ public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -625,7 +615,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria /** * Use the Group relation Group object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -641,28 +631,27 @@ abstract class BaseGroupResourceQuery extends ModelCriteria } /** - * Filter the query by a related Resource object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Resource|ObjectCollection $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. + * @return ChildGroupResourceQuery The current query, for fluid interface */ public function filterByResource($resource, $comparison = null) { - if ($resource instanceof Resource) { + if ($resource instanceof \Thelia\Model\Resource) { return $this - ->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->getId(), $comparison); - } elseif ($resource instanceof PropelObjectCollection) { + ->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resource->getId(), $comparison); + } elseif ($resource instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection'); + throw new PropelException('filterByResource() only accepts arguments of type \Thelia\Model\Resource or Collection'); } } @@ -672,7 +661,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * @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 + * @return ChildGroupResourceQuery The current query, for fluid interface */ public function joinResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -701,7 +690,7 @@ abstract class BaseGroupResourceQuery extends ModelCriteria /** * Use the Resource relation Resource object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -719,22 +708,97 @@ abstract class BaseGroupResourceQuery extends ModelCriteria /** * Exclude object from result * - * @param GroupResource $groupResource Object to remove from the list of results + * @param ChildGroupResource $groupResource Object to remove from the list of results * - * @return GroupResourceQuery The current query, for fluid interface + * @return ChildGroupResourceQuery 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->addCond('pruneCond0', $this->getAliasedColName(GroupResourceTableMap::ID), $groupResource->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(GroupResourceTableMap::GROUP_ID), $groupResource->getGroupId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond2', $this->getAliasedColName(GroupResourceTableMap::RESOURCE_ID), $groupResource->getResourceId(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); } return $this; } + /** + * Deletes all rows from the group_resource table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + GroupResourceTableMap::clearInstancePool(); + GroupResourceTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildGroupResource or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildGroupResource object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(GroupResourceTableMap::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(); + + + GroupResourceTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + GroupResourceTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -742,31 +806,11 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return GroupResourceQuery The current query, for fluid interface + * @return ChildGroupResourceQuery 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); + return $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -774,30 +818,51 @@ abstract class BaseGroupResourceQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return GroupResourceQuery The current query, for fluid interface + * @return ChildGroupResourceQuery 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); + return $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildGroupResourceQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(GroupResourceTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildGroupResourceQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(GroupResourceTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return GroupResourceQuery The current query, for fluid interface + * @return ChildGroupResourceQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(GroupResourcePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(GroupResourceTableMap::CREATED_AT); } /** * Order by create date asc * - * @return GroupResourceQuery The current query, for fluid interface + * @return ChildGroupResourceQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(GroupResourcePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(GroupResourceTableMap::CREATED_AT); } -} + +} // GroupResourceQuery diff --git a/core/lib/Thelia/Model/om/BaseImage.php b/core/lib/Thelia/Model/Base/Image.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseImage.php rename to core/lib/Thelia/Model/Base/Image.php index 8443cb379..50538aa1a --- a/core/lib/Thelia/Model/om/BaseImage.php +++ b/core/lib/Thelia/Model/Base/Image.php @@ -1,61 +1,69 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Image instance. If + * obj is an instance of Image, delegates to + * equals(Image). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Image The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Image The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [product_id] column value. * - * @return int + * @return int */ public function getProductId() { + return $this->product_id; } /** * Get the [category_id] column value. * - * @return int + * @return int */ public function getCategoryId() { + return $this->category_id; } /** * Get the [folder_id] column value. * - * @return int + * @return int */ public function getFolderId() { + return $this->folder_id; } /** * Get the [content_id] column value. * - * @return int + * @return int */ public function getContentId() { + return $this->content_id; } /** * Get the [file] column value. * - * @return string + * @return string */ public function getFile() { + return $this->file; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -251,97 +508,57 @@ abstract class BaseImage extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Image The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = ImagePeer::ID; + $this->modifiedColumns[] = ImageTableMap::ID; } @@ -351,18 +568,18 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [product_id] column. * - * @param int $v new value - * @return Image The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Image The current object (for fluent API support) */ public function setProductId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->product_id !== $v) { $this->product_id = $v; - $this->modifiedColumns[] = ImagePeer::PRODUCT_ID; + $this->modifiedColumns[] = ImageTableMap::PRODUCT_ID; } if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { @@ -376,18 +593,18 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [category_id] column. * - * @param int $v new value - * @return Image The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Image The current object (for fluent API support) */ public function setCategoryId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->category_id !== $v) { $this->category_id = $v; - $this->modifiedColumns[] = ImagePeer::CATEGORY_ID; + $this->modifiedColumns[] = ImageTableMap::CATEGORY_ID; } if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { @@ -401,18 +618,18 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [folder_id] column. * - * @param int $v new value - * @return Image The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Image The current object (for fluent API support) */ public function setFolderId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->folder_id !== $v) { $this->folder_id = $v; - $this->modifiedColumns[] = ImagePeer::FOLDER_ID; + $this->modifiedColumns[] = ImageTableMap::FOLDER_ID; } if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { @@ -426,18 +643,18 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [content_id] column. * - * @param int $v new value - * @return Image The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Image The current object (for fluent API support) */ public function setContentId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->content_id !== $v) { $this->content_id = $v; - $this->modifiedColumns[] = ImagePeer::CONTENT_ID; + $this->modifiedColumns[] = ImageTableMap::CONTENT_ID; } if ($this->aContent !== null && $this->aContent->getId() !== $v) { @@ -451,18 +668,18 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [file] column. * - * @param string $v new value - * @return Image The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Image The current object (for fluent API support) */ public function setFile($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->file !== $v) { $this->file = $v; - $this->modifiedColumns[] = ImagePeer::FILE; + $this->modifiedColumns[] = ImageTableMap::FILE; } @@ -472,18 +689,18 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return Image The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Image The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = ImagePeer::POSITION; + $this->modifiedColumns[] = ImageTableMap::POSITION; } @@ -493,19 +710,17 @@ abstract class BaseImage extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Image The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ImageTableMap::CREATED_AT; } } // if either are not null @@ -516,19 +731,17 @@ abstract class BaseImage extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Image The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ImageTableMap::UPDATED_AT; } } // if either are not null @@ -546,7 +759,7 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -558,25 +771,53 @@ abstract class BaseImage extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ImageTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ImageTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ImageTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->folder_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ImageTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ImageTableMap::translateFieldName('File', TableMap::TYPE_PHPNAME, $indexType)]; + $this->file = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ImageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ImageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -584,11 +825,11 @@ abstract class BaseImage extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 9; // 9 = ImagePeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 9; // 9 = ImageTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Image object", $e); + throw new PropelException("Error populating \Thelia\Model\Image object", 0, $e); } } @@ -607,7 +848,6 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { $this->aProduct = null; } @@ -627,12 +867,12 @@ abstract class BaseImage extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -643,19 +883,19 @@ abstract class BaseImage extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ImageTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -671,26 +911,25 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Image::setDeleted() + * @see Image::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ImageQuery::create() + $deleteQuery = ChildImageQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -715,20 +954,19 @@ abstract class BaseImage extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -738,16 +976,16 @@ abstract class BaseImage extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(ImagePeer::CREATED_AT)) { + if (!$this->isColumnModified(ImageTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(ImagePeer::UPDATED_AT)) { + if (!$this->isColumnModified(ImageTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ImagePeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(ImageTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -759,7 +997,7 @@ abstract class BaseImage extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - ImagePeer::addInstanceToPool($this); + ImageTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -778,19 +1016,19 @@ abstract class BaseImage extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -835,15 +1073,15 @@ abstract class BaseImage extends BaseObject implements Persistent if ($this->imageI18nsScheduledForDeletion !== null) { if (!$this->imageI18nsScheduledForDeletion->isEmpty()) { - ImageI18nQuery::create() + \Thelia\Model\ImageI18nQuery::create() ->filterByPrimaryKeys($this->imageI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->imageI18nsScheduledForDeletion = null; } } - if ($this->collImageI18ns !== null) { - foreach ($this->collImageI18ns as $referrerFK) { + if ($this->collImageI18ns !== null) { + foreach ($this->collImageI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -860,52 +1098,52 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = ImagePeer::ID; + $this->modifiedColumns[] = ImageTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ImagePeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ImageTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ImagePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(ImageTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ImagePeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; + if ($this->isColumnModified(ImageTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; } - if ($this->isColumnModified(ImagePeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; + if ($this->isColumnModified(ImageTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; } - if ($this->isColumnModified(ImagePeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`folder_id`'; + if ($this->isColumnModified(ImageTableMap::FOLDER_ID)) { + $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; } - if ($this->isColumnModified(ImagePeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`content_id`'; + if ($this->isColumnModified(ImageTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; } - if ($this->isColumnModified(ImagePeer::FILE)) { - $modifiedColumns[':p' . $index++] = '`file`'; + if ($this->isColumnModified(ImageTableMap::FILE)) { + $modifiedColumns[':p' . $index++] = 'FILE'; } - if ($this->isColumnModified(ImagePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(ImageTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(ImagePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(ImageTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(ImagePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(ImageTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `image` (%s) VALUES (%s)', + 'INSERT INTO image (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -914,45 +1152,45 @@ abstract class BaseImage extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`product_id`': + case 'PRODUCT_ID': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`category_id`': + case 'CATEGORY_ID': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`folder_id`': + case 'FOLDER_ID': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; - case '`content_id`': + case 'CONTENT_ID': $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); break; - case '`file`': + case 'FILE': $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -962,142 +1200,32 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = ImagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1107,7 +1235,7 @@ abstract class BaseImage extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1152,22 +1280,22 @@ abstract class BaseImage extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = ImageTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getProductId(), @@ -1179,6 +1307,12 @@ abstract class BaseImage extends BaseObject implements Persistent $keys[7] => $this->getCreatedAt(), $keys[8] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aProduct) { $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -1203,27 +1337,27 @@ abstract class BaseImage extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = ImagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1268,17 +1402,17 @@ abstract class BaseImage extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = ImagePeer::getFieldNames($keyType); + $keys = ImageTableMap::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]]); @@ -1298,17 +1432,17 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(ImagePeer::DATABASE_NAME); + $criteria = new Criteria(ImageTableMap::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); + if ($this->isColumnModified(ImageTableMap::ID)) $criteria->add(ImageTableMap::ID, $this->id); + if ($this->isColumnModified(ImageTableMap::PRODUCT_ID)) $criteria->add(ImageTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(ImageTableMap::CATEGORY_ID)) $criteria->add(ImageTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(ImageTableMap::FOLDER_ID)) $criteria->add(ImageTableMap::FOLDER_ID, $this->folder_id); + if ($this->isColumnModified(ImageTableMap::CONTENT_ID)) $criteria->add(ImageTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(ImageTableMap::FILE)) $criteria->add(ImageTableMap::FILE, $this->file); + if ($this->isColumnModified(ImageTableMap::POSITION)) $criteria->add(ImageTableMap::POSITION, $this->position); + if ($this->isColumnModified(ImageTableMap::CREATED_AT)) $criteria->add(ImageTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ImageTableMap::UPDATED_AT)) $criteria->add(ImageTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1323,15 +1457,15 @@ abstract class BaseImage extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(ImagePeer::DATABASE_NAME); - $criteria->add(ImagePeer::ID, $this->id); + $criteria = new Criteria(ImageTableMap::DATABASE_NAME); + $criteria->add(ImageTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1341,7 +1475,7 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1365,9 +1499,9 @@ abstract class BaseImage extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1381,12 +1515,10 @@ abstract class BaseImage extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1394,8 +1526,6 @@ abstract class BaseImage extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1412,8 +1542,8 @@ abstract class BaseImage extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Image Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1427,31 +1557,13 @@ abstract class BaseImage extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildProduct object. * - * 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) + * @param ChildProduct $v + * @return \Thelia\Model\Image The current object (for fluent API support) * @throws PropelException */ - public function setProduct(Product $v = null) + public function setProduct(ChildProduct $v = null) { if ($v === null) { $this->setProductId(NULL); @@ -1462,7 +1574,7 @@ abstract class BaseImage extends BaseObject implements Persistent $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 this object has already been added to the ChildProduct object, it will not be re-added. if ($v !== null) { $v->addImage($this); } @@ -1473,17 +1585,16 @@ abstract class BaseImage extends BaseObject implements Persistent /** - * Get the associated Product object + * Get the associated ChildProduct object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null, $doQuery = true) + public function getProduct(ConnectionInterface $con = null) { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::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 @@ -1497,13 +1608,13 @@ abstract class BaseImage extends BaseObject implements Persistent } /** - * Declares an association between this object and a Category object. + * Declares an association between this object and a ChildCategory object. * - * @param Category $v - * @return Image The current object (for fluent API support) + * @param ChildCategory $v + * @return \Thelia\Model\Image The current object (for fluent API support) * @throws PropelException */ - public function setCategory(Category $v = null) + public function setCategory(ChildCategory $v = null) { if ($v === null) { $this->setCategoryId(NULL); @@ -1514,7 +1625,7 @@ abstract class BaseImage extends BaseObject implements Persistent $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 this object has already been added to the ChildCategory object, it will not be re-added. if ($v !== null) { $v->addImage($this); } @@ -1525,17 +1636,16 @@ abstract class BaseImage extends BaseObject implements Persistent /** - * Get the associated Category object + * Get the associated ChildCategory object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null, $doQuery = true) + public function getCategory(ConnectionInterface $con = null) { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::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 @@ -1549,13 +1659,13 @@ abstract class BaseImage extends BaseObject implements Persistent } /** - * Declares an association between this object and a Content object. + * Declares an association between this object and a ChildContent object. * - * @param Content $v - * @return Image The current object (for fluent API support) + * @param ChildContent $v + * @return \Thelia\Model\Image The current object (for fluent API support) * @throws PropelException */ - public function setContent(Content $v = null) + public function setContent(ChildContent $v = null) { if ($v === null) { $this->setContentId(NULL); @@ -1566,7 +1676,7 @@ abstract class BaseImage extends BaseObject implements Persistent $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 this object has already been added to the ChildContent object, it will not be re-added. if ($v !== null) { $v->addImage($this); } @@ -1577,17 +1687,16 @@ abstract class BaseImage extends BaseObject implements Persistent /** - * Get the associated Content object + * Get the associated ChildContent object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. * @throws PropelException */ - public function getContent(PropelPDO $con = null, $doQuery = true) + public function getContent(ConnectionInterface $con = null) { - if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::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 @@ -1601,13 +1710,13 @@ abstract class BaseImage extends BaseObject implements Persistent } /** - * Declares an association between this object and a Folder object. + * Declares an association between this object and a ChildFolder object. * - * @param Folder $v - * @return Image The current object (for fluent API support) + * @param ChildFolder $v + * @return \Thelia\Model\Image The current object (for fluent API support) * @throws PropelException */ - public function setFolder(Folder $v = null) + public function setFolder(ChildFolder $v = null) { if ($v === null) { $this->setFolderId(NULL); @@ -1618,7 +1727,7 @@ abstract class BaseImage extends BaseObject implements Persistent $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 this object has already been added to the ChildFolder object, it will not be re-added. if ($v !== null) { $v->addImage($this); } @@ -1629,17 +1738,16 @@ abstract class BaseImage extends BaseObject implements Persistent /** - * Get the associated Folder object + * Get the associated ChildFolder object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Folder The associated Folder object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFolder The associated ChildFolder object. * @throws PropelException */ - public function getFolder(PropelPDO $con = null, $doQuery = true) + public function getFolder(ConnectionInterface $con = null) { - if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { - $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); + if ($this->aFolder === null && ($this->folder_id !== null)) { + $this->aFolder = ChildFolderQuery::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 @@ -1658,13 +1766,13 @@ abstract class BaseImage extends BaseObject implements Persistent * 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('ImageI18n' == $relationName) { - $this->initImageI18ns(); + return $this->initImageI18ns(); } } @@ -1674,21 +1782,16 @@ abstract class BaseImage extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collImageI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collImageI18ns collection loaded partially - * - * @return void + * Reset is the collImageI18ns collection loaded partially. */ public function resetPartialImageI18ns($v = true) { @@ -1702,7 +1805,7 @@ abstract class BaseImage extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1712,25 +1815,25 @@ abstract class BaseImage extends BaseObject implements Persistent if (null !== $this->collImageI18ns && !$overrideExisting) { return; } - $this->collImageI18ns = new PropelObjectCollection(); - $this->collImageI18ns->setModel('ImageI18n'); + $this->collImageI18ns = new ObjectCollection(); + $this->collImageI18ns->setModel('\Thelia\Model\ImageI18n'); } /** - * Gets an array of ImageI18n objects which contain a foreign key that references this object. + * Gets an array of ChildImageI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildImage is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildImageI18n[] List of ChildImageI18n objects * @throws PropelException */ - public function getImageI18ns($criteria = null, PropelPDO $con = null) + public function getImageI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collImageI18nsPartial && !$this->isNew(); if (null === $this->collImageI18ns || null !== $criteria || $partial) { @@ -1738,29 +1841,31 @@ abstract class BaseImage extends BaseObject implements Persistent // return empty collection $this->initImageI18ns(); } else { - $collImageI18ns = ImageI18nQuery::create(null, $criteria) + $collImageI18ns = ChildImageI18nQuery::create(null, $criteria) ->filterByImage($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collImageI18nsPartial && count($collImageI18ns)) { - $this->initImageI18ns(false); + $this->initImageI18ns(false); - foreach($collImageI18ns as $obj) { - if (false == $this->collImageI18ns->contains($obj)) { - $this->collImageI18ns->append($obj); + foreach ($collImageI18ns as $obj) { + if (false == $this->collImageI18ns->contains($obj)) { + $this->collImageI18ns->append($obj); + } } - } - $this->collImageI18nsPartial = true; + $this->collImageI18nsPartial = true; } $collImageI18ns->getInternalIterator()->rewind(); + return $collImageI18ns; } - if($partial && $this->collImageI18ns) { - foreach($this->collImageI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collImageI18ns) { + foreach ($this->collImageI18ns as $obj) { + if ($obj->isNew()) { $collImageI18ns[] = $obj; } } @@ -1780,15 +1885,19 @@ abstract class BaseImage extends BaseObject implements Persistent * It will 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) + * @param Collection $imageI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildImage The current object (for fluent API support) */ - public function setImageI18ns(PropelCollection $imageI18ns, PropelPDO $con = null) + public function setImageI18ns(Collection $imageI18ns, ConnectionInterface $con = null) { $imageI18nsToDelete = $this->getImageI18ns(new Criteria(), $con)->diff($imageI18ns); - $this->imageI18nsScheduledForDeletion = unserialize(serialize($imageI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->imageI18nsScheduledForDeletion = clone $imageI18nsToDelete; foreach ($imageI18nsToDelete as $imageI18nRemoved) { $imageI18nRemoved->setImage(null); @@ -1808,13 +1917,13 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Returns the number of related ImageI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ImageI18n objects. * @throws PropelException */ - public function countImageI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collImageI18nsPartial && !$this->isNew(); if (null === $this->collImageI18ns || null !== $criteria || $partial) { @@ -1822,10 +1931,11 @@ abstract class BaseImage extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getImageI18ns()); } - $query = ImageI18nQuery::create(null, $criteria); + + $query = ChildImageI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1839,13 +1949,13 @@ abstract class BaseImage extends BaseObject implements Persistent } /** - * Method called to associate a ImageI18n object to this object - * through the ImageI18n foreign key attribute. + * Method called to associate a ChildImageI18n object to this object + * through the ChildImageI18n foreign key attribute. * - * @param ImageI18n $l ImageI18n - * @return Image The current object (for fluent API support) + * @param ChildImageI18n $l ChildImageI18n + * @return \Thelia\Model\Image The current object (for fluent API support) */ - public function addImageI18n(ImageI18n $l) + public function addImageI18n(ChildImageI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1855,6 +1965,7 @@ abstract class BaseImage extends BaseObject implements Persistent $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); } @@ -1863,7 +1974,7 @@ abstract class BaseImage extends BaseObject implements Persistent } /** - * @param ImageI18n $imageI18n The imageI18n object to add. + * @param ImageI18n $imageI18n The imageI18n object to add. */ protected function doAddImageI18n($imageI18n) { @@ -1872,8 +1983,8 @@ abstract class BaseImage extends BaseObject implements Persistent } /** - * @param ImageI18n $imageI18n The imageI18n object to remove. - * @return Image The current object (for fluent API support) + * @param ImageI18n $imageI18n The imageI18n object to remove. + * @return ChildImage The current object (for fluent API support) */ public function removeImageI18n($imageI18n) { @@ -1905,8 +2016,6 @@ abstract class BaseImage extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1918,40 +2027,25 @@ abstract class BaseImage extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { 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->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collImageI18ns instanceof PropelCollection) { + if ($this->collImageI18ns instanceof Collection) { $this->collImageI18ns->clearIterator(); } $this->collImageI18ns = null; @@ -1962,23 +2056,13 @@ abstract class BaseImage extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(ImageTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1986,11 +2070,11 @@ abstract class BaseImage extends BaseObject implements Persistent /** * 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) + * @return ChildImage The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = ImagePeer::UPDATED_AT; + $this->modifiedColumns[] = ImageTableMap::UPDATED_AT; return $this; } @@ -2002,9 +2086,9 @@ abstract class BaseImage extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Image The current object (for fluent API support) + * @return ChildImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2025,10 +2109,10 @@ abstract class BaseImage extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return ImageI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildImageI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collImageI18ns) { @@ -2041,10 +2125,10 @@ abstract class BaseImage extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new ImageI18n(); + $translation = new ChildImageI18n(); $translation->setLocale($locale); } else { - $translation = ImageI18nQuery::create() + $translation = ChildImageI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -2059,14 +2143,14 @@ abstract class BaseImage extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Image The current object (for fluent API support) + * @return ChildImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - ImageI18nQuery::create() + ChildImageI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -2086,10 +2170,10 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return ImageI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildImageI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -2098,7 +2182,7 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -2109,8 +2193,8 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ImageI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2122,7 +2206,7 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -2133,8 +2217,8 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ImageI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2146,7 +2230,7 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -2157,8 +2241,8 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ImageI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2170,7 +2254,7 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -2181,8 +2265,8 @@ abstract class BaseImage extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ImageI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -2190,4 +2274,122 @@ abstract class BaseImage extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/ImageI18n.php b/core/lib/Thelia/Model/Base/ImageI18n.php new file mode 100644 index 000000000..324f939e9 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ImageI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ImageI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ImageI18n instance. If + * obj is an instance of ImageI18n, delegates to + * equals(ImageI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ImageI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ImageI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\ImageI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ImageI18nTableMap::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 \Thelia\Model\ImageI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ImageI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ImageI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ImageI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ImageI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ImageI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ImageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ImageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ImageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ImageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ImageI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ImageI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ImageI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ImageI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ImageI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildImageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aImage = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ImageI18n::setDeleted() + * @see ImageI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildImageI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + } + + $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); + ImageI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ImageI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ImageI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ImageI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ImageI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ImageI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ImageI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ImageI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ImageI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ImageI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ImageI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ImageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ImageI18nTableMap::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(ImageI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ImageI18nTableMap::ID)) $criteria->add(ImageI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ImageI18nTableMap::LOCALE)) $criteria->add(ImageI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ImageI18nTableMap::TITLE)) $criteria->add(ImageI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ImageI18nTableMap::DESCRIPTION)) $criteria->add(ImageI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ImageI18nTableMap::CHAPO)) $criteria->add(ImageI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ImageI18nTableMap::POSTSCRIPTUM)) $criteria->add(ImageI18nTableMap::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(ImageI18nTableMap::DATABASE_NAME); + $criteria->add(ImageI18nTableMap::ID, $this->id); + $criteria->add(ImageI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildImage object. + * + * @param ChildImage $v + * @return \Thelia\Model\ImageI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setImage(ChildImage $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 ChildImage object, it will not be re-added. + if ($v !== null) { + $v->addImageI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildImage object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildImage The associated ChildImage object. + * @throws PropelException + */ + public function getImage(ConnectionInterface $con = null) + { + if ($this->aImage === null && ($this->id !== null)) { + $this->aImage = ChildImageQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aImage = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ImageI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseImageI18nQuery.php b/core/lib/Thelia/Model/Base/ImageI18nQuery.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseImageI18nQuery.php rename to core/lib/Thelia/Model/Base/ImageI18nQuery.php index be9c773a5..92fa1d878 --- a/core/lib/Thelia/Model/om/BaseImageI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ImageI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseImageI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ImageI18n|ImageI18n[]|mixed the result, formatted by the current formatter + * @return ChildImageI18n|array|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 + if ((null !== ($obj = ImageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ImageI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseImageI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ImageI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildImageI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `image_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseImageI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ImageI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildImageI18n(); $obj->hydrate($row); - ImageI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ImageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseImageI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ImageI18n|ImageI18n[]|mixed the result, formatted by the current formatter + * @return ChildImageI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseImageI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ImageI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseImageI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ImageI18nQuery The current query, for fluid interface + * @return ChildImageI18nQuery 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); + $this->addUsingAlias(ImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ImageI18nQuery The current query, for fluid interface + * @return ChildImageI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseImageI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(ImageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ImageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByImage() @@ -270,18 +266,18 @@ abstract class BaseImageI18nQuery extends ModelCriteria * 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 + * @return ChildImageI18nQuery 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); + $this->addUsingAlias(ImageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ImageI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ImageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(ImageI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria * 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 + * @return ChildImageI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(ImageI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria * 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 + * @return ChildImageI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(ImageI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria * 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 + * @return ChildImageI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(ImageI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria * 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 + * @return ChildImageI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(ImageI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria * 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 + * @return ChildImageI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseImageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ImageI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(ImageI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Image object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Image|ObjectCollection $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. + * @return ChildImageI18nQuery The current query, for fluid interface */ public function filterByImage($image, $comparison = null) { - if ($image instanceof Image) { + if ($image instanceof \Thelia\Model\Image) { return $this - ->addUsingAlias(ImageI18nPeer::ID, $image->getId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { + ->addUsingAlias(ImageI18nTableMap::ID, $image->getId(), $comparison); + } elseif ($image instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ImageI18nPeer::ID, $image->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ImageI18nTableMap::ID, $image->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); + throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria * @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 + * @return ChildImageI18nQuery The current query, for fluid interface */ public function joinImage($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseImageI18nQuery extends ModelCriteria /** * Use the Image relation Image object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseImageI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param ImageI18n $imageI18n Object to remove from the list of results + * @param ChildImageI18n $imageI18n Object to remove from the list of results * - * @return ImageI18nQuery The current query, for fluid interface + * @return ChildImageI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(ImageI18nTableMap::ID), $imageI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ImageI18nTableMap::LOCALE), $imageI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ImageI18nTableMap::clearInstancePool(); + ImageI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildImageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildImageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ImageI18nTableMap::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(); + + + ImageI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ImageI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ImageI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseImageQuery.php b/core/lib/Thelia/Model/Base/ImageQuery.php old mode 100755 new mode 100644 similarity index 58% rename from core/lib/Thelia/Model/om/BaseImageQuery.php rename to core/lib/Thelia/Model/Base/ImageQuery.php index 44279b45d..6e16a885b --- a/core/lib/Thelia/Model/om/BaseImageQuery.php +++ b/core/lib/Thelia/Model/Base/ImageQuery.php @@ -1,127 +1,124 @@ setModelAlias($modelAlias); } @@ -142,21 +139,21 @@ abstract class BaseImageQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Image|Image[]|mixed the result, formatted by the current formatter + * @return ChildImage|array|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 + if ((null !== ($obj = ImageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ImageTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -168,46 +165,31 @@ abstract class BaseImageQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Image A model object, or null if the key is not found - * @throws PropelException + * @return ChildImage A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Image(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildImage(); $obj->hydrate($row); - ImagePeer::addInstanceToPool($obj, (string) $key); + ImageTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -218,19 +200,19 @@ abstract class BaseImageQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Image|Image[]|mixed the result, formatted by the current formatter + * @return ChildImage|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -239,22 +221,22 @@ abstract class BaseImageQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Image[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -262,12 +244,12 @@ abstract class BaseImageQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ImageQuery The current query, for fluid interface + * @return ChildImageQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(ImagePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(ImageTableMap::ID, $key, Criteria::EQUAL); } /** @@ -275,12 +257,12 @@ abstract class BaseImageQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ImageQuery The current query, for fluid interface + * @return ChildImageQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(ImagePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(ImageTableMap::ID, $keys, Criteria::IN); } /** @@ -290,8 +272,7 @@ abstract class BaseImageQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -300,18 +281,18 @@ abstract class BaseImageQuery extends ModelCriteria * 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 + * @return ChildImageQuery 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); + $this->addUsingAlias(ImageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ImagePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ImageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -322,7 +303,7 @@ abstract class BaseImageQuery extends ModelCriteria } } - return $this->addUsingAlias(ImagePeer::ID, $id, $comparison); + return $this->addUsingAlias(ImageTableMap::ID, $id, $comparison); } /** @@ -332,8 +313,7 @@ abstract class BaseImageQuery extends ModelCriteria * * $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 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 * * * @see filterByProduct() @@ -344,18 +324,18 @@ abstract class BaseImageQuery extends ModelCriteria * 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 + * @return ChildImageQuery 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); + $this->addUsingAlias(ImageTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($productId['max'])) { - $this->addUsingAlias(ImagePeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ImageTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -366,7 +346,7 @@ abstract class BaseImageQuery extends ModelCriteria } } - return $this->addUsingAlias(ImagePeer::PRODUCT_ID, $productId, $comparison); + return $this->addUsingAlias(ImageTableMap::PRODUCT_ID, $productId, $comparison); } /** @@ -376,8 +356,7 @@ abstract class BaseImageQuery extends ModelCriteria * * $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 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 * * * @see filterByCategory() @@ -388,18 +367,18 @@ abstract class BaseImageQuery extends ModelCriteria * 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 + * @return ChildImageQuery 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); + $this->addUsingAlias(ImageTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($categoryId['max'])) { - $this->addUsingAlias(ImagePeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ImageTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -410,7 +389,7 @@ abstract class BaseImageQuery extends ModelCriteria } } - return $this->addUsingAlias(ImagePeer::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(ImageTableMap::CATEGORY_ID, $categoryId, $comparison); } /** @@ -420,8 +399,7 @@ abstract class BaseImageQuery extends ModelCriteria * * $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 + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 * * * @see filterByFolder() @@ -432,18 +410,18 @@ abstract class BaseImageQuery extends ModelCriteria * 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 + * @return ChildImageQuery 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); + $this->addUsingAlias(ImageTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($folderId['max'])) { - $this->addUsingAlias(ImagePeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ImageTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -454,7 +432,7 @@ abstract class BaseImageQuery extends ModelCriteria } } - return $this->addUsingAlias(ImagePeer::FOLDER_ID, $folderId, $comparison); + return $this->addUsingAlias(ImageTableMap::FOLDER_ID, $folderId, $comparison); } /** @@ -464,8 +442,7 @@ abstract class BaseImageQuery extends ModelCriteria * * $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 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 * * * @see filterByContent() @@ -476,18 +453,18 @@ abstract class BaseImageQuery extends ModelCriteria * 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 + * @return ChildImageQuery 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); + $this->addUsingAlias(ImageTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($contentId['max'])) { - $this->addUsingAlias(ImagePeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ImageTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -498,7 +475,7 @@ abstract class BaseImageQuery extends ModelCriteria } } - return $this->addUsingAlias(ImagePeer::CONTENT_ID, $contentId, $comparison); + return $this->addUsingAlias(ImageTableMap::CONTENT_ID, $contentId, $comparison); } /** @@ -514,7 +491,7 @@ abstract class BaseImageQuery extends ModelCriteria * 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 + * @return ChildImageQuery The current query, for fluid interface */ public function filterByFile($file = null, $comparison = null) { @@ -527,7 +504,7 @@ abstract class BaseImageQuery extends ModelCriteria } } - return $this->addUsingAlias(ImagePeer::FILE, $file, $comparison); + return $this->addUsingAlias(ImageTableMap::FILE, $file, $comparison); } /** @@ -537,8 +514,7 @@ abstract class BaseImageQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -547,18 +523,18 @@ abstract class BaseImageQuery extends ModelCriteria * 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 + * @return ChildImageQuery 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); + $this->addUsingAlias(ImageTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(ImagePeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ImageTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -569,7 +545,7 @@ abstract class BaseImageQuery extends ModelCriteria } } - return $this->addUsingAlias(ImagePeer::POSITION, $position, $comparison); + return $this->addUsingAlias(ImageTableMap::POSITION, $position, $comparison); } /** @@ -590,18 +566,18 @@ abstract class BaseImageQuery extends ModelCriteria * 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 + * @return ChildImageQuery 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); + $this->addUsingAlias(ImageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ImagePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ImageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -612,7 +588,7 @@ abstract class BaseImageQuery extends ModelCriteria } } - return $this->addUsingAlias(ImagePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ImageTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -633,18 +609,18 @@ abstract class BaseImageQuery extends ModelCriteria * 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 + * @return ChildImageQuery 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); + $this->addUsingAlias(ImageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ImagePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ImageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -655,32 +631,31 @@ abstract class BaseImageQuery extends ModelCriteria } } - return $this->addUsingAlias(ImagePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ImageTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildImageQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(ImagePeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(ImageTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ImagePeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ImageTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -690,7 +665,7 @@ abstract class BaseImageQuery extends ModelCriteria * @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 + * @return ChildImageQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -719,7 +694,7 @@ abstract class BaseImageQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -735,28 +710,27 @@ abstract class BaseImageQuery extends ModelCriteria } /** - * Filter the query by a related Category object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Category|ObjectCollection $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. + * @return ChildImageQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = null) { - if ($category instanceof Category) { + if ($category instanceof \Thelia\Model\Category) { return $this - ->addUsingAlias(ImagePeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { + ->addUsingAlias(ImageTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ImagePeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ImageTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); } } @@ -766,7 +740,7 @@ abstract class BaseImageQuery extends ModelCriteria * @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 + * @return ChildImageQuery The current query, for fluid interface */ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -795,7 +769,7 @@ abstract class BaseImageQuery extends ModelCriteria /** * Use the Category relation Category object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -811,28 +785,27 @@ abstract class BaseImageQuery extends ModelCriteria } /** - * Filter the query by a related Content object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Content|ObjectCollection $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. + * @return ChildImageQuery The current query, for fluid interface */ public function filterByContent($content, $comparison = null) { - if ($content instanceof Content) { + if ($content instanceof \Thelia\Model\Content) { return $this - ->addUsingAlias(ImagePeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { + ->addUsingAlias(ImageTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ImagePeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ImageTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); } } @@ -842,7 +815,7 @@ abstract class BaseImageQuery extends ModelCriteria * @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 + * @return ChildImageQuery The current query, for fluid interface */ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -871,7 +844,7 @@ abstract class BaseImageQuery extends ModelCriteria /** * Use the Content relation Content object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -887,28 +860,27 @@ abstract class BaseImageQuery extends ModelCriteria } /** - * Filter the query by a related Folder object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Folder|ObjectCollection $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. + * @return ChildImageQuery The current query, for fluid interface */ public function filterByFolder($folder, $comparison = null) { - if ($folder instanceof Folder) { + if ($folder instanceof \Thelia\Model\Folder) { return $this - ->addUsingAlias(ImagePeer::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { + ->addUsingAlias(ImageTableMap::FOLDER_ID, $folder->getId(), $comparison); + } elseif ($folder instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ImagePeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ImageTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); + throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); } } @@ -918,7 +890,7 @@ abstract class BaseImageQuery extends ModelCriteria * @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 + * @return ChildImageQuery The current query, for fluid interface */ public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -947,7 +919,7 @@ abstract class BaseImageQuery extends ModelCriteria /** * Use the Folder relation Folder object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -963,26 +935,25 @@ abstract class BaseImageQuery extends ModelCriteria } /** - * Filter the query by a related ImageI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ImageI18n|ObjectCollection $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. + * @return ChildImageQuery The current query, for fluid interface */ public function filterByImageI18n($imageI18n, $comparison = null) { - if ($imageI18n instanceof ImageI18n) { + if ($imageI18n instanceof \Thelia\Model\ImageI18n) { return $this - ->addUsingAlias(ImagePeer::ID, $imageI18n->getId(), $comparison); - } elseif ($imageI18n instanceof PropelObjectCollection) { + ->addUsingAlias(ImageTableMap::ID, $imageI18n->getId(), $comparison); + } elseif ($imageI18n instanceof ObjectCollection) { return $this ->useImageI18nQuery() ->filterByPrimaryKeys($imageI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByImageI18n() only accepts arguments of type ImageI18n or PropelCollection'); + throw new PropelException('filterByImageI18n() only accepts arguments of type \Thelia\Model\ImageI18n or Collection'); } } @@ -992,7 +963,7 @@ abstract class BaseImageQuery extends ModelCriteria * @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 + * @return ChildImageQuery The current query, for fluid interface */ public function joinImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -1021,7 +992,7 @@ abstract class BaseImageQuery extends ModelCriteria /** * Use the ImageI18n relation ImageI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1039,19 +1010,94 @@ abstract class BaseImageQuery extends ModelCriteria /** * Exclude object from result * - * @param Image $image Object to remove from the list of results + * @param ChildImage $image Object to remove from the list of results * - * @return ImageQuery The current query, for fluid interface + * @return ChildImageQuery The current query, for fluid interface */ public function prune($image = null) { if ($image) { - $this->addUsingAlias(ImagePeer::ID, $image->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(ImageTableMap::ID, $image->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ImageTableMap::clearInstancePool(); + ImageTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildImage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildImage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ImageTableMap::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(); + + + ImageTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ImageTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -1059,31 +1105,11 @@ abstract class BaseImageQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ImageQuery The current query, for fluid interface + * @return ChildImageQuery 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); + return $this->addUsingAlias(ImageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -1091,32 +1117,53 @@ abstract class BaseImageQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ImageQuery The current query, for fluid interface + * @return ChildImageQuery 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); + return $this->addUsingAlias(ImageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildImageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ImageTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildImageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ImageTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ImageQuery The current query, for fluid interface + * @return ChildImageQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(ImagePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(ImageTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ImageQuery The current query, for fluid interface + * @return ChildImageQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(ImagePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(ImageTableMap::CREATED_AT); } + // i18n behavior /** @@ -1126,9 +1173,9 @@ abstract class BaseImageQuery extends ModelCriteria * @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 + * @return ChildImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ImageI18n'; @@ -1144,9 +1191,9 @@ abstract class BaseImageQuery extends ModelCriteria * @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 + * @return ChildImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1165,13 +1212,13 @@ abstract class BaseImageQuery extends ModelCriteria * @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 + * @return ChildImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ImageI18n', 'Thelia\Model\ImageI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'ImageI18n', '\Thelia\Model\ImageI18nQuery'); } -} +} // ImageQuery diff --git a/core/lib/Thelia/Model/Base/Lang.php b/core/lib/Thelia/Model/Base/Lang.php new file mode 100644 index 000000000..694f86bc5 --- /dev/null +++ b/core/lib/Thelia/Model/Base/Lang.php @@ -0,0 +1,1507 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Lang instance. If + * obj is an instance of Lang, delegates to + * equals(Lang). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Lang The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Lang The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\Lang The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = LangTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\Lang The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = LangTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [code] column. + * + * @param string $v new value + * @return \Thelia\Model\Lang The current object (for fluent API support) + */ + public function setCode($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->code !== $v) { + $this->code = $v; + $this->modifiedColumns[] = LangTableMap::CODE; + } + + + return $this; + } // setCode() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\Lang The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = LangTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [url] column. + * + * @param string $v new value + * @return \Thelia\Model\Lang The current object (for fluent API support) + */ + public function setUrl($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->url !== $v) { + $this->url = $v; + $this->modifiedColumns[] = LangTableMap::URL; + } + + + return $this; + } // setUrl() + + /** + * Set the value of [by_default] column. + * + * @param int $v new value + * @return \Thelia\Model\Lang The current object (for fluent API support) + */ + public function setByDefault($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->by_default !== $v) { + $this->by_default = $v; + $this->modifiedColumns[] = LangTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = LangTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = LangTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : LangTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : LangTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : LangTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : LangTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : LangTableMap::translateFieldName('Url', TableMap::TYPE_PHPNAME, $indexType)]; + $this->url = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : LangTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->by_default = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : LangTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : LangTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 8; // 8 = LangTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\Lang object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(LangTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildLangQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see Lang::setDeleted() + * @see Lang::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildLangQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(LangTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(LangTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(LangTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + LangTableMap::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 ConnectionInterface $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(ConnectionInterface $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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = LangTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . LangTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(LangTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(LangTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(LangTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; + } + if ($this->isColumnModified(LangTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(LangTableMap::URL)) { + $modifiedColumns[':p' . $index++] = 'URL'; + } + if ($this->isColumnModified(LangTableMap::BY_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'BY_DEFAULT'; + } + if ($this->isColumnModified(LangTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(LangTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = LangTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['Lang'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Lang'][$this->getPrimaryKey()] = true; + $keys = LangTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = LangTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = LangTableMap::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(LangTableMap::DATABASE_NAME); + + if ($this->isColumnModified(LangTableMap::ID)) $criteria->add(LangTableMap::ID, $this->id); + if ($this->isColumnModified(LangTableMap::TITLE)) $criteria->add(LangTableMap::TITLE, $this->title); + if ($this->isColumnModified(LangTableMap::CODE)) $criteria->add(LangTableMap::CODE, $this->code); + if ($this->isColumnModified(LangTableMap::LOCALE)) $criteria->add(LangTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(LangTableMap::URL)) $criteria->add(LangTableMap::URL, $this->url); + if ($this->isColumnModified(LangTableMap::BY_DEFAULT)) $criteria->add(LangTableMap::BY_DEFAULT, $this->by_default); + if ($this->isColumnModified(LangTableMap::CREATED_AT)) $criteria->add(LangTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(LangTableMap::UPDATED_AT)) $criteria->add(LangTableMap::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(LangTableMap::DATABASE_NAME); + $criteria->add(LangTableMap::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 \Thelia\Model\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 \Thelia\Model\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; + } + + /** + * 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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(LangTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildLang The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = LangTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseLangQuery.php b/core/lib/Thelia/Model/Base/LangQuery.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseLangQuery.php rename to core/lib/Thelia/Model/Base/LangQuery.php index 10105802e..1a99ff28a --- a/core/lib/Thelia/Model/om/BaseLangQuery.php +++ b/core/lib/Thelia/Model/Base/LangQuery.php @@ -1,96 +1,96 @@ setModelAlias($modelAlias); } @@ -111,21 +111,21 @@ abstract class BaseLangQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Lang|Lang[]|mixed the result, formatted by the current formatter + * @return ChildLang|array|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 + if ((null !== ($obj = LangTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(LangTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -137,46 +137,31 @@ abstract class BaseLangQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Lang A model object, or null if the key is not found - * @throws PropelException + * @return ChildLang A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `title`, `code`, `locale`, `url`, `by_default`, `created_at`, `updated_at` FROM `lang` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Lang(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildLang(); $obj->hydrate($row); - LangPeer::addInstanceToPool($obj, (string) $key); + LangTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -187,19 +172,19 @@ abstract class BaseLangQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Lang|Lang[]|mixed the result, formatted by the current formatter + * @return ChildLang|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -208,22 +193,22 @@ abstract class BaseLangQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Lang[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -231,12 +216,12 @@ abstract class BaseLangQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return LangQuery The current query, for fluid interface + * @return ChildLangQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(LangPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(LangTableMap::ID, $key, Criteria::EQUAL); } /** @@ -244,12 +229,12 @@ abstract class BaseLangQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return LangQuery The current query, for fluid interface + * @return ChildLangQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(LangPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(LangTableMap::ID, $keys, Criteria::IN); } /** @@ -259,8 +244,7 @@ abstract class BaseLangQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -269,18 +253,18 @@ abstract class BaseLangQuery extends ModelCriteria * 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 + * @return ChildLangQuery 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); + $this->addUsingAlias(LangTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(LangPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(LangTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -291,7 +275,7 @@ abstract class BaseLangQuery extends ModelCriteria } } - return $this->addUsingAlias(LangPeer::ID, $id, $comparison); + return $this->addUsingAlias(LangTableMap::ID, $id, $comparison); } /** @@ -307,7 +291,7 @@ abstract class BaseLangQuery extends ModelCriteria * 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 + * @return ChildLangQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -320,7 +304,7 @@ abstract class BaseLangQuery extends ModelCriteria } } - return $this->addUsingAlias(LangPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(LangTableMap::TITLE, $title, $comparison); } /** @@ -336,7 +320,7 @@ abstract class BaseLangQuery extends ModelCriteria * 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 + * @return ChildLangQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -349,7 +333,7 @@ abstract class BaseLangQuery extends ModelCriteria } } - return $this->addUsingAlias(LangPeer::CODE, $code, $comparison); + return $this->addUsingAlias(LangTableMap::CODE, $code, $comparison); } /** @@ -365,7 +349,7 @@ abstract class BaseLangQuery extends ModelCriteria * 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 + * @return ChildLangQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -378,7 +362,7 @@ abstract class BaseLangQuery extends ModelCriteria } } - return $this->addUsingAlias(LangPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(LangTableMap::LOCALE, $locale, $comparison); } /** @@ -394,7 +378,7 @@ abstract class BaseLangQuery extends ModelCriteria * 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 + * @return ChildLangQuery The current query, for fluid interface */ public function filterByUrl($url = null, $comparison = null) { @@ -407,7 +391,7 @@ abstract class BaseLangQuery extends ModelCriteria } } - return $this->addUsingAlias(LangPeer::URL, $url, $comparison); + return $this->addUsingAlias(LangTableMap::URL, $url, $comparison); } /** @@ -417,8 +401,7 @@ abstract class BaseLangQuery extends ModelCriteria * * $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 + * $query->filterByByDefault(array('min' => 12)); // WHERE by_default > 12 * * * @param mixed $byDefault The value to use as filter. @@ -427,18 +410,18 @@ abstract class BaseLangQuery extends ModelCriteria * 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 + * @return ChildLangQuery 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); + $this->addUsingAlias(LangTableMap::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($byDefault['max'])) { - $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(LangTableMap::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -449,7 +432,7 @@ abstract class BaseLangQuery extends ModelCriteria } } - return $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault, $comparison); + return $this->addUsingAlias(LangTableMap::BY_DEFAULT, $byDefault, $comparison); } /** @@ -470,18 +453,18 @@ abstract class BaseLangQuery extends ModelCriteria * 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 + * @return ChildLangQuery 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); + $this->addUsingAlias(LangTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(LangTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -492,7 +475,7 @@ abstract class BaseLangQuery extends ModelCriteria } } - return $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(LangTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -513,18 +496,18 @@ abstract class BaseLangQuery extends ModelCriteria * 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 + * @return ChildLangQuery 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); + $this->addUsingAlias(LangTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(LangTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -535,25 +518,100 @@ abstract class BaseLangQuery extends ModelCriteria } } - return $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(LangTableMap::UPDATED_AT, $updatedAt, $comparison); } /** * Exclude object from result * - * @param Lang $lang Object to remove from the list of results + * @param ChildLang $lang Object to remove from the list of results * - * @return LangQuery The current query, for fluid interface + * @return ChildLangQuery The current query, for fluid interface */ public function prune($lang = null) { if ($lang) { - $this->addUsingAlias(LangPeer::ID, $lang->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(LangTableMap::ID, $lang->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the lang table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + LangTableMap::clearInstancePool(); + LangTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildLang or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildLang object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(LangTableMap::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(); + + + LangTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + LangTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -561,31 +619,11 @@ abstract class BaseLangQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return LangQuery The current query, for fluid interface + * @return ChildLangQuery 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); + return $this->addUsingAlias(LangTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -593,30 +631,51 @@ abstract class BaseLangQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return LangQuery The current query, for fluid interface + * @return ChildLangQuery 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); + return $this->addUsingAlias(LangTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildLangQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(LangTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildLangQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(LangTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return LangQuery The current query, for fluid interface + * @return ChildLangQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(LangPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(LangTableMap::CREATED_AT); } /** * Order by create date asc * - * @return LangQuery The current query, for fluid interface + * @return ChildLangQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(LangPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(LangTableMap::CREATED_AT); } -} + +} // LangQuery diff --git a/core/lib/Thelia/Model/om/BaseMessage.php b/core/lib/Thelia/Model/Base/Message.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseMessage.php rename to core/lib/Thelia/Model/Base/Message.php index 09686a988..f39e4ecbe --- a/core/lib/Thelia/Model/om/BaseMessage.php +++ b/core/lib/Thelia/Model/Base/Message.php @@ -1,56 +1,64 @@ applyDefaultValues(); } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Message instance. If + * obj is an instance of Message, delegates to + * equals(Message). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Message The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Message The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [code] column value. * - * @return string + * @return string */ public function getCode() { + return $this->code; } /** * Get the [secured] column value. * - * @return int + * @return int */ public function getSecured() { + return $this->secured; } /** * Get the [ref] column value. * - * @return string + * @return string */ public function getRef() { + return $this->ref; } @@ -238,89 +484,50 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version] column value. * - * @return int + * @return int */ public function getVersion() { + return $this->version; } @@ -328,67 +535,48 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getVersionCreatedAt($format = NULL) { - 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; + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version_created_by] column value. * - * @return string + * @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) + * @param int $v new value + * @return \Thelia\Model\Message The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = MessagePeer::ID; + $this->modifiedColumns[] = MessageTableMap::ID; } @@ -398,18 +586,18 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Set the value of [code] column. * - * @param string $v new value - * @return Message The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Message The current object (for fluent API support) */ public function setCode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->code !== $v) { $this->code = $v; - $this->modifiedColumns[] = MessagePeer::CODE; + $this->modifiedColumns[] = MessageTableMap::CODE; } @@ -419,18 +607,18 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Set the value of [secured] column. * - * @param int $v new value - * @return Message The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Message The current object (for fluent API support) */ public function setSecured($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->secured !== $v) { $this->secured = $v; - $this->modifiedColumns[] = MessagePeer::SECURED; + $this->modifiedColumns[] = MessageTableMap::SECURED; } @@ -440,18 +628,18 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Set the value of [ref] column. * - * @param string $v new value - * @return Message The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Message The current object (for fluent API support) */ public function setRef($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->ref !== $v) { $this->ref = $v; - $this->modifiedColumns[] = MessagePeer::REF; + $this->modifiedColumns[] = MessageTableMap::REF; } @@ -461,19 +649,17 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Message The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = MessageTableMap::CREATED_AT; } } // if either are not null @@ -484,19 +670,17 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Message The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = MessageTableMap::UPDATED_AT; } } // if either are not null @@ -507,18 +691,18 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Set the value of [version] column. * - * @param int $v new value - * @return Message The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Message The current object (for fluent API support) */ public function setVersion($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->version !== $v) { $this->version = $v; - $this->modifiedColumns[] = MessagePeer::VERSION; + $this->modifiedColumns[] = MessageTableMap::VERSION; } @@ -528,19 +712,17 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Message The current object (for fluent API support) */ public function setVersionCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = MessageTableMap::VERSION_CREATED_AT; } } // if either are not null @@ -551,18 +733,18 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Set the value of [version_created_by] column. * - * @param string $v new value - * @return Message The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Message The current object (for fluent API support) */ public function setVersionCreatedBy($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->version_created_by !== $v) { $this->version_created_by = $v; - $this->modifiedColumns[] = MessagePeer::VERSION_CREATED_BY; + $this->modifiedColumns[] = MessageTableMap::VERSION_CREATED_BY; } @@ -583,7 +765,7 @@ abstract class BaseMessage extends BaseObject implements Persistent return false; } - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -595,25 +777,56 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MessageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MessageTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MessageTableMap::translateFieldName('Secured', TableMap::TYPE_PHPNAME, $indexType)]; + $this->secured = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : MessageTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : MessageTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : MessageTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : MessageTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : MessageTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : MessageTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -621,11 +834,11 @@ abstract class BaseMessage extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 9; // 9 = MessagePeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 9; // 9 = MessageTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Message object", $e); + throw new PropelException("Error populating \Thelia\Model\Message object", 0, $e); } } @@ -644,7 +857,6 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -652,12 +864,12 @@ abstract class BaseMessage extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -668,19 +880,19 @@ abstract class BaseMessage extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(MessageTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildMessageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -694,26 +906,25 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Message::setDeleted() + * @see Message::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = MessageQuery::create() + $deleteQuery = ChildMessageQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -738,20 +949,19 @@ abstract class BaseMessage extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -761,7 +971,7 @@ abstract class BaseMessage extends BaseObject implements Persistent // versionable behavior if ($this->isVersioningNecessary()) { $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1); - if (!$this->isColumnModified(MessagePeer::VERSION_CREATED_AT)) { + if (!$this->isColumnModified(MessageTableMap::VERSION_CREATED_AT)) { $this->setVersionCreatedAt(time()); } $createVersion = true; // for postSave hook @@ -769,16 +979,16 @@ abstract class BaseMessage extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(MessagePeer::CREATED_AT)) { + if (!$this->isColumnModified(MessageTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(MessagePeer::UPDATED_AT)) { + if (!$this->isColumnModified(MessageTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(MessagePeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(MessageTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -794,7 +1004,7 @@ abstract class BaseMessage extends BaseObject implements Persistent if (isset($createVersion)) { $this->addVersion($con); } - MessagePeer::addInstanceToPool($this); + MessageTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -813,12 +1023,12 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -837,15 +1047,15 @@ abstract class BaseMessage extends BaseObject implements Persistent if ($this->messageI18nsScheduledForDeletion !== null) { if (!$this->messageI18nsScheduledForDeletion->isEmpty()) { - MessageI18nQuery::create() + \Thelia\Model\MessageI18nQuery::create() ->filterByPrimaryKeys($this->messageI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->messageI18nsScheduledForDeletion = null; } } - if ($this->collMessageI18ns !== null) { - foreach ($this->collMessageI18ns as $referrerFK) { + if ($this->collMessageI18ns !== null) { + foreach ($this->collMessageI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -854,15 +1064,15 @@ abstract class BaseMessage extends BaseObject implements Persistent if ($this->messageVersionsScheduledForDeletion !== null) { if (!$this->messageVersionsScheduledForDeletion->isEmpty()) { - MessageVersionQuery::create() + \Thelia\Model\MessageVersionQuery::create() ->filterByPrimaryKeys($this->messageVersionsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->messageVersionsScheduledForDeletion = null; } } - if ($this->collMessageVersions !== null) { - foreach ($this->collMessageVersions as $referrerFK) { + if ($this->collMessageVersions !== null) { + foreach ($this->collMessageVersions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -879,52 +1089,52 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = MessagePeer::ID; + $this->modifiedColumns[] = MessageTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . MessagePeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . MessageTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(MessagePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(MessageTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(MessagePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; + if ($this->isColumnModified(MessageTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(MessagePeer::SECURED)) { - $modifiedColumns[':p' . $index++] = '`secured`'; + if ($this->isColumnModified(MessageTableMap::SECURED)) { + $modifiedColumns[':p' . $index++] = 'SECURED'; } - if ($this->isColumnModified(MessagePeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; + if ($this->isColumnModified(MessageTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; } - if ($this->isColumnModified(MessagePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(MessageTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(MessagePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(MessageTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } - if ($this->isColumnModified(MessagePeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`version`'; + if ($this->isColumnModified(MessageTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; } - if ($this->isColumnModified(MessagePeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`version_created_at`'; + if ($this->isColumnModified(MessageTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; } - if ($this->isColumnModified(MessagePeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`version_created_by`'; + if ($this->isColumnModified(MessageTableMap::VERSION_CREATED_BY)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY'; } $sql = sprintf( - 'INSERT INTO `message` (%s) VALUES (%s)', + 'INSERT INTO message (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -933,31 +1143,31 @@ abstract class BaseMessage extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`code`': + case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`secured`': + case 'SECURED': $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT); break; - case '`ref`': + case 'REF': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version`': + 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); + case 'VERSION_CREATED_AT': + $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version_created_by`': + case 'VERSION_CREATED_BY': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -965,13 +1175,13 @@ abstract class BaseMessage extends BaseObject implements Persistent $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -981,120 +1191,32 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = MessageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1104,7 +1226,7 @@ abstract class BaseMessage extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1149,22 +1271,22 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = MessageTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), @@ -1176,6 +1298,12 @@ abstract class BaseMessage extends BaseObject implements Persistent $keys[7] => $this->getVersionCreatedAt(), $keys[8] => $this->getVersionCreatedBy(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collMessageI18ns) { $result['MessageI18ns'] = $this->collMessageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1191,27 +1319,27 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = MessageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1256,17 +1384,17 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = MessagePeer::getFieldNames($keyType); + $keys = MessageTableMap::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]]); @@ -1286,17 +1414,17 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(MessagePeer::DATABASE_NAME); + $criteria = new Criteria(MessageTableMap::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); + if ($this->isColumnModified(MessageTableMap::ID)) $criteria->add(MessageTableMap::ID, $this->id); + if ($this->isColumnModified(MessageTableMap::CODE)) $criteria->add(MessageTableMap::CODE, $this->code); + if ($this->isColumnModified(MessageTableMap::SECURED)) $criteria->add(MessageTableMap::SECURED, $this->secured); + if ($this->isColumnModified(MessageTableMap::REF)) $criteria->add(MessageTableMap::REF, $this->ref); + if ($this->isColumnModified(MessageTableMap::CREATED_AT)) $criteria->add(MessageTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(MessageTableMap::UPDATED_AT)) $criteria->add(MessageTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(MessageTableMap::VERSION)) $criteria->add(MessageTableMap::VERSION, $this->version); + if ($this->isColumnModified(MessageTableMap::VERSION_CREATED_AT)) $criteria->add(MessageTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(MessageTableMap::VERSION_CREATED_BY)) $criteria->add(MessageTableMap::VERSION_CREATED_BY, $this->version_created_by); return $criteria; } @@ -1311,15 +1439,15 @@ abstract class BaseMessage extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(MessagePeer::DATABASE_NAME); - $criteria->add(MessagePeer::ID, $this->id); + $criteria = new Criteria(MessageTableMap::DATABASE_NAME); + $criteria->add(MessageTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1329,7 +1457,7 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1353,9 +1481,9 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1369,12 +1497,10 @@ abstract class BaseMessage extends BaseObject implements Persistent $copyObj->setVersionCreatedAt($this->getVersionCreatedAt()); $copyObj->setVersionCreatedBy($this->getVersionCreatedBy()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1388,8 +1514,6 @@ abstract class BaseMessage extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1406,8 +1530,8 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Message Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1420,40 +1544,22 @@ abstract class BaseMessage extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('MessageI18n' == $relationName) { - $this->initMessageI18ns(); + return $this->initMessageI18ns(); } if ('MessageVersion' == $relationName) { - $this->initMessageVersions(); + return $this->initMessageVersions(); } } @@ -1463,21 +1569,16 @@ abstract class BaseMessage extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collMessageI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collMessageI18ns collection loaded partially - * - * @return void + * Reset is the collMessageI18ns collection loaded partially. */ public function resetPartialMessageI18ns($v = true) { @@ -1491,7 +1592,7 @@ abstract class BaseMessage extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1501,25 +1602,25 @@ abstract class BaseMessage extends BaseObject implements Persistent if (null !== $this->collMessageI18ns && !$overrideExisting) { return; } - $this->collMessageI18ns = new PropelObjectCollection(); - $this->collMessageI18ns->setModel('MessageI18n'); + $this->collMessageI18ns = new ObjectCollection(); + $this->collMessageI18ns->setModel('\Thelia\Model\MessageI18n'); } /** - * Gets an array of MessageI18n objects which contain a foreign key that references this object. + * Gets an array of ChildMessageI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildMessage is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildMessageI18n[] List of ChildMessageI18n objects * @throws PropelException */ - public function getMessageI18ns($criteria = null, PropelPDO $con = null) + public function getMessageI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collMessageI18nsPartial && !$this->isNew(); if (null === $this->collMessageI18ns || null !== $criteria || $partial) { @@ -1527,29 +1628,31 @@ abstract class BaseMessage extends BaseObject implements Persistent // return empty collection $this->initMessageI18ns(); } else { - $collMessageI18ns = MessageI18nQuery::create(null, $criteria) + $collMessageI18ns = ChildMessageI18nQuery::create(null, $criteria) ->filterByMessage($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collMessageI18nsPartial && count($collMessageI18ns)) { - $this->initMessageI18ns(false); + $this->initMessageI18ns(false); - foreach($collMessageI18ns as $obj) { - if (false == $this->collMessageI18ns->contains($obj)) { - $this->collMessageI18ns->append($obj); + foreach ($collMessageI18ns as $obj) { + if (false == $this->collMessageI18ns->contains($obj)) { + $this->collMessageI18ns->append($obj); + } } - } - $this->collMessageI18nsPartial = true; + $this->collMessageI18nsPartial = true; } $collMessageI18ns->getInternalIterator()->rewind(); + return $collMessageI18ns; } - if($partial && $this->collMessageI18ns) { - foreach($this->collMessageI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collMessageI18ns) { + foreach ($this->collMessageI18ns as $obj) { + if ($obj->isNew()) { $collMessageI18ns[] = $obj; } } @@ -1569,15 +1672,19 @@ abstract class BaseMessage extends BaseObject implements Persistent * It will 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) + * @param Collection $messageI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildMessage The current object (for fluent API support) */ - public function setMessageI18ns(PropelCollection $messageI18ns, PropelPDO $con = null) + public function setMessageI18ns(Collection $messageI18ns, ConnectionInterface $con = null) { $messageI18nsToDelete = $this->getMessageI18ns(new Criteria(), $con)->diff($messageI18ns); - $this->messageI18nsScheduledForDeletion = unserialize(serialize($messageI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->messageI18nsScheduledForDeletion = clone $messageI18nsToDelete; foreach ($messageI18nsToDelete as $messageI18nRemoved) { $messageI18nRemoved->setMessage(null); @@ -1597,13 +1704,13 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Returns the number of related MessageI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related MessageI18n objects. * @throws PropelException */ - public function countMessageI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countMessageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collMessageI18nsPartial && !$this->isNew(); if (null === $this->collMessageI18ns || null !== $criteria || $partial) { @@ -1611,10 +1718,11 @@ abstract class BaseMessage extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getMessageI18ns()); } - $query = MessageI18nQuery::create(null, $criteria); + + $query = ChildMessageI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1628,13 +1736,13 @@ abstract class BaseMessage extends BaseObject implements Persistent } /** - * Method called to associate a MessageI18n object to this object - * through the MessageI18n foreign key attribute. + * Method called to associate a ChildMessageI18n object to this object + * through the ChildMessageI18n foreign key attribute. * - * @param MessageI18n $l MessageI18n - * @return Message The current object (for fluent API support) + * @param ChildMessageI18n $l ChildMessageI18n + * @return \Thelia\Model\Message The current object (for fluent API support) */ - public function addMessageI18n(MessageI18n $l) + public function addMessageI18n(ChildMessageI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1644,6 +1752,7 @@ abstract class BaseMessage extends BaseObject implements Persistent $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); } @@ -1652,7 +1761,7 @@ abstract class BaseMessage extends BaseObject implements Persistent } /** - * @param MessageI18n $messageI18n The messageI18n object to add. + * @param MessageI18n $messageI18n The messageI18n object to add. */ protected function doAddMessageI18n($messageI18n) { @@ -1661,8 +1770,8 @@ abstract class BaseMessage extends BaseObject implements Persistent } /** - * @param MessageI18n $messageI18n The messageI18n object to remove. - * @return Message The current object (for fluent API support) + * @param MessageI18n $messageI18n The messageI18n object to remove. + * @return ChildMessage The current object (for fluent API support) */ public function removeMessageI18n($messageI18n) { @@ -1685,21 +1794,16 @@ abstract class BaseMessage extends BaseObject implements Persistent * This 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) + * @return void * @see addMessageVersions() */ public function clearMessageVersions() { - $this->collMessageVersions = null; // important to set this to null since that means it is uninitialized - $this->collMessageVersionsPartial = null; - - return $this; + $this->collMessageVersions = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collMessageVersions collection loaded partially - * - * @return void + * Reset is the collMessageVersions collection loaded partially. */ public function resetPartialMessageVersions($v = true) { @@ -1713,7 +1817,7 @@ abstract class BaseMessage extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1723,25 +1827,25 @@ abstract class BaseMessage extends BaseObject implements Persistent if (null !== $this->collMessageVersions && !$overrideExisting) { return; } - $this->collMessageVersions = new PropelObjectCollection(); - $this->collMessageVersions->setModel('MessageVersion'); + $this->collMessageVersions = new ObjectCollection(); + $this->collMessageVersions->setModel('\Thelia\Model\MessageVersion'); } /** - * Gets an array of MessageVersion objects which contain a foreign key that references this object. + * Gets an array of ChildMessageVersion objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildMessage is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildMessageVersion[] List of ChildMessageVersion objects * @throws PropelException */ - public function getMessageVersions($criteria = null, PropelPDO $con = null) + public function getMessageVersions($criteria = null, ConnectionInterface $con = null) { $partial = $this->collMessageVersionsPartial && !$this->isNew(); if (null === $this->collMessageVersions || null !== $criteria || $partial) { @@ -1749,29 +1853,31 @@ abstract class BaseMessage extends BaseObject implements Persistent // return empty collection $this->initMessageVersions(); } else { - $collMessageVersions = MessageVersionQuery::create(null, $criteria) + $collMessageVersions = ChildMessageVersionQuery::create(null, $criteria) ->filterByMessage($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collMessageVersionsPartial && count($collMessageVersions)) { - $this->initMessageVersions(false); + $this->initMessageVersions(false); - foreach($collMessageVersions as $obj) { - if (false == $this->collMessageVersions->contains($obj)) { - $this->collMessageVersions->append($obj); + foreach ($collMessageVersions as $obj) { + if (false == $this->collMessageVersions->contains($obj)) { + $this->collMessageVersions->append($obj); + } } - } - $this->collMessageVersionsPartial = true; + $this->collMessageVersionsPartial = true; } $collMessageVersions->getInternalIterator()->rewind(); + return $collMessageVersions; } - if($partial && $this->collMessageVersions) { - foreach($this->collMessageVersions as $obj) { - if($obj->isNew()) { + if ($partial && $this->collMessageVersions) { + foreach ($this->collMessageVersions as $obj) { + if ($obj->isNew()) { $collMessageVersions[] = $obj; } } @@ -1791,15 +1897,19 @@ abstract class BaseMessage extends BaseObject implements Persistent * It will 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) + * @param Collection $messageVersions A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildMessage The current object (for fluent API support) */ - public function setMessageVersions(PropelCollection $messageVersions, PropelPDO $con = null) + public function setMessageVersions(Collection $messageVersions, ConnectionInterface $con = null) { $messageVersionsToDelete = $this->getMessageVersions(new Criteria(), $con)->diff($messageVersions); - $this->messageVersionsScheduledForDeletion = unserialize(serialize($messageVersionsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->messageVersionsScheduledForDeletion = clone $messageVersionsToDelete; foreach ($messageVersionsToDelete as $messageVersionRemoved) { $messageVersionRemoved->setMessage(null); @@ -1819,13 +1929,13 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Returns the number of related MessageVersion objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related MessageVersion objects. * @throws PropelException */ - public function countMessageVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countMessageVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collMessageVersionsPartial && !$this->isNew(); if (null === $this->collMessageVersions || null !== $criteria || $partial) { @@ -1833,10 +1943,11 @@ abstract class BaseMessage extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getMessageVersions()); } - $query = MessageVersionQuery::create(null, $criteria); + + $query = ChildMessageVersionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1850,18 +1961,19 @@ abstract class BaseMessage extends BaseObject implements Persistent } /** - * Method called to associate a MessageVersion object to this object - * through the MessageVersion foreign key attribute. + * Method called to associate a ChildMessageVersion object to this object + * through the ChildMessageVersion foreign key attribute. * - * @param MessageVersion $l MessageVersion - * @return Message The current object (for fluent API support) + * @param ChildMessageVersion $l ChildMessageVersion + * @return \Thelia\Model\Message The current object (for fluent API support) */ - public function addMessageVersion(MessageVersion $l) + public function addMessageVersion(ChildMessageVersion $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); } @@ -1870,7 +1982,7 @@ abstract class BaseMessage extends BaseObject implements Persistent } /** - * @param MessageVersion $messageVersion The messageVersion object to add. + * @param MessageVersion $messageVersion The messageVersion object to add. */ protected function doAddMessageVersion($messageVersion) { @@ -1879,8 +1991,8 @@ abstract class BaseMessage extends BaseObject implements Persistent } /** - * @param MessageVersion $messageVersion The messageVersion object to remove. - * @return Message The current object (for fluent API support) + * @param MessageVersion $messageVersion The messageVersion object to remove. + * @return ChildMessage The current object (for fluent API support) */ public function removeMessageVersion($messageVersion) { @@ -1912,8 +2024,6 @@ abstract class BaseMessage extends BaseObject implements Persistent $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(); @@ -1926,14 +2036,13 @@ abstract class BaseMessage extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collMessageI18ns) { foreach ($this->collMessageI18ns as $o) { $o->clearAllReferences($deep); @@ -1944,42 +2053,30 @@ abstract class BaseMessage extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collMessageI18ns instanceof PropelCollection) { + if ($this->collMessageI18ns instanceof Collection) { $this->collMessageI18ns->clearIterator(); } $this->collMessageI18ns = null; - if ($this->collMessageVersions instanceof PropelCollection) { + if ($this->collMessageVersions instanceof Collection) { $this->collMessageVersions->clearIterator(); } $this->collMessageVersions = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(MessageTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1987,11 +2084,11 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * 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) + * @return ChildMessage The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = MessagePeer::UPDATED_AT; + $this->modifiedColumns[] = MessageTableMap::UPDATED_AT; return $this; } @@ -2003,9 +2100,9 @@ abstract class BaseMessage extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Message The current object (for fluent API support) + * @return ChildMessage The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2026,10 +2123,10 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return MessageI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildMessageI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collMessageI18ns) { @@ -2042,10 +2139,10 @@ abstract class BaseMessage extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new MessageI18n(); + $translation = new ChildMessageI18n(); $translation->setLocale($locale); } else { - $translation = MessageI18nQuery::create() + $translation = ChildMessageI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -2060,14 +2157,14 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Message The current object (for fluent API support) + * @return ChildMessage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - MessageI18nQuery::create() + ChildMessageI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -2087,10 +2184,10 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return MessageI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildMessageI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -2099,7 +2196,7 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -2110,8 +2207,8 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\MessageI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2123,7 +2220,7 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -2134,8 +2231,8 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\MessageI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2147,7 +2244,7 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Get the [description_html] column value. * - * @return string + * @return string */ public function getDescriptionHtml() { @@ -2158,8 +2255,8 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Set the value of [description_html] column. * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\MessageI18n The current object (for fluent API support) */ public function setDescriptionHtml($v) { $this->getCurrentTranslation()->setDescriptionHtml($v); @@ -2172,7 +2269,7 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Enforce a new Version of this object upon next save. * - * @return Message + * @return \Thelia\Model\Message */ public function enforceVersioning() { @@ -2184,8 +2281,6 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * 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) @@ -2198,7 +2293,7 @@ abstract class BaseMessage extends BaseObject implements Persistent return true; } - if (MessagePeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) { + if (ChildMessageQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) { return true; } @@ -2208,15 +2303,15 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Creates a version of the current object and saves it. * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return MessageVersion A version object + * @return ChildMessageVersion A version object */ public function addVersion($con = null) { $this->enforceVersion = false; - $version = new MessageVersion(); + $version = new ChildMessageVersion(); $version->setId($this->getId()); $version->setCode($this->getCode()); $version->setSecured($this->getSecured()); @@ -2233,19 +2328,18 @@ abstract class BaseMessage extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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 + * @param ConnectionInterface $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. + * @return ChildMessage The current object (for fluent API support) */ 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)); + throw new PropelException(sprintf('No ChildMessage object found with version %d', $version)); } $this->populateFromVersion($version, $con); @@ -2253,18 +2347,17 @@ abstract class BaseMessage extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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. + * @param ChildMessageVersion $version The version object to use + * @param ConnectionInterface $con the connection to use + * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects. * - * @return Message The current object (for fluent API support) + * @return ChildMessage The current object (for fluent API support) */ public function populateFromVersion($version, $con = null, &$loadedObjects = array()) { - - $loadedObjects['Message'][$version->getId()][$version->getVersion()] = $this; + $loadedObjects['ChildMessage'][$version->getId()][$version->getVersion()] = $this; $this->setId($version->getId()); $this->setCode($version->getCode()); $this->setSecured($version->getSecured()); @@ -2281,13 +2374,13 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Gets the latest persisted version number for the current object * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * * @return integer */ public function getLastVersionNumber($con = null) { - $v = MessageVersionQuery::create() + $v = ChildMessageVersionQuery::create() ->filterByMessage($this) ->orderByVersion('desc') ->findOne($con); @@ -2301,9 +2394,9 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Checks whether the current object is the latest one * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return boolean + * @return Boolean */ public function isLastVersion($con = null) { @@ -2314,13 +2407,13 @@ abstract class BaseMessage extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con the connection to use * - * @return MessageVersion A version object + * @return ChildMessageVersion A version object */ public function getOneVersion($versionNumber, $con = null) { - return MessageVersionQuery::create() + return ChildMessageVersionQuery::create() ->filterByMessage($this) ->filterByVersion($versionNumber) ->findOne($con); @@ -2329,14 +2422,14 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Gets all the versions of this object, in incremental order * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return PropelObjectCollection A list of MessageVersion objects + * @return ObjectCollection A list of ChildMessageVersion objects */ public function getAllVersions($con = null) { $criteria = new Criteria(); - $criteria->addAscendingOrderByColumn(MessageVersionPeer::VERSION); + $criteria->addAscendingOrderByColumn(MessageVersionTableMap::VERSION); return $this->getMessageVersions($criteria, $con); } @@ -2351,10 +2444,10 @@ abstract class BaseMessage extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $versionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -2376,11 +2469,11 @@ abstract class BaseMessage extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $fromVersionNumber + * @param integer $toVersionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -2395,7 +2488,7 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * Computes the diff between two versions. * - * print_r($this->computeDiff(1, 2)); + * print_r($book->computeDiff(1, 2)); * => array( * '1' => array('Title' => 'Book title at version 1'), * '2' => array('Title' => 'Book title at version 2') @@ -2444,18 +2537,133 @@ abstract class BaseMessage extends BaseObject implements Persistent /** * 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 + * @param Integer $number the number of record to return. + * @return PropelCollection|array \Thelia\Model\MessageVersion[] List of \Thelia\Model\MessageVersion objects */ - public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null) + public function getLastVersions($number = 10, $criteria = null, $con = null) { - $criteria = MessageVersionQuery::create(null, $criteria); - $criteria->addDescendingOrderByColumn(MessageVersionPeer::VERSION); + $criteria = ChildMessageVersionQuery::create(null, $criteria); + $criteria->addDescendingOrderByColumn(MessageVersionTableMap::VERSION); $criteria->limit($number); return $this->getMessageVersions($criteria, $con); } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/MessageI18n.php b/core/lib/Thelia/Model/Base/MessageI18n.php new file mode 100644 index 000000000..545e75244 --- /dev/null +++ b/core/lib/Thelia/Model/Base/MessageI18n.php @@ -0,0 +1,1381 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\MessageI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another MessageI18n instance. If + * obj is an instance of MessageI18n, delegates to + * equals(MessageI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return MessageI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return MessageI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\MessageI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = MessageI18nTableMap::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 \Thelia\Model\MessageI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = MessageI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\MessageI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = MessageI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\MessageI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = MessageI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [description_html] column. + * + * @param string $v new value + * @return \Thelia\Model\MessageI18n The current object (for fluent API support) + */ + public function setDescriptionHtml($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description_html !== $v) { + $this->description_html = $v; + $this->modifiedColumns[] = MessageI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MessageI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MessageI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MessageI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : MessageI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : MessageI18nTableMap::translateFieldName('DescriptionHtml', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description_html = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = MessageI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\MessageI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(MessageI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildMessageI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aMessage = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see MessageI18n::setDeleted() + * @see MessageI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildMessageI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME); + } + + $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); + MessageI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(MessageI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(MessageI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(MessageI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(MessageI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(MessageI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = MessageI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['MessageI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['MessageI18n'][serialize($this->getPrimaryKey())] = true; + $keys = MessageI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getDescriptionHtml(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = MessageI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = MessageI18nTableMap::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(MessageI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(MessageI18nTableMap::ID)) $criteria->add(MessageI18nTableMap::ID, $this->id); + if ($this->isColumnModified(MessageI18nTableMap::LOCALE)) $criteria->add(MessageI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(MessageI18nTableMap::TITLE)) $criteria->add(MessageI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(MessageI18nTableMap::DESCRIPTION)) $criteria->add(MessageI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(MessageI18nTableMap::DESCRIPTION_HTML)) $criteria->add(MessageI18nTableMap::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(MessageI18nTableMap::DATABASE_NAME); + $criteria->add(MessageI18nTableMap::ID, $this->id); + $criteria->add(MessageI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildMessage object. + * + * @param ChildMessage $v + * @return \Thelia\Model\MessageI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setMessage(ChildMessage $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 ChildMessage object, it will not be re-added. + if ($v !== null) { + $v->addMessageI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildMessage object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildMessage The associated ChildMessage object. + * @throws PropelException + */ + public function getMessage(ConnectionInterface $con = null) + { + if ($this->aMessage === null && ($this->id !== null)) { + $this->aMessage = ChildMessageQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aMessage = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(MessageI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseMessageI18nQuery.php b/core/lib/Thelia/Model/Base/MessageI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseMessageI18nQuery.php rename to core/lib/Thelia/Model/Base/MessageI18nQuery.php index 8e584eece..478c737e8 --- a/core/lib/Thelia/Model/om/BaseMessageI18nQuery.php +++ b/core/lib/Thelia/Model/Base/MessageI18nQuery.php @@ -1,92 +1,91 @@ setModelAlias($modelAlias); } @@ -106,23 +105,22 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return MessageI18n|MessageI18n[]|mixed the result, formatted by the current formatter + * @return ChildMessageI18n|array|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 + if ((null !== ($obj = MessageI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(MessageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(MessageI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -139,14 +137,13 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return MessageI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildMessageI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `description_html` FROM `message_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -154,13 +151,13 @@ abstract class BaseMessageI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new MessageI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildMessageI18n(); $obj->hydrate($row); - MessageI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + MessageI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -171,19 +168,19 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return MessageI18n|MessageI18n[]|mixed the result, formatted by the current formatter + * @return ChildMessageI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -192,22 +189,22 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|MessageI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -215,12 +212,12 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return MessageI18nQuery The current query, for fluid interface + * @return ChildMessageI18nQuery 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); + $this->addUsingAlias(MessageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(MessageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -230,7 +227,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return MessageI18nQuery The current query, for fluid interface + * @return ChildMessageI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -238,8 +235,8 @@ abstract class BaseMessageI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(MessageI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(MessageI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -254,8 +251,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByMessage() @@ -266,18 +262,18 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * 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 + * @return ChildMessageI18nQuery 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); + $this->addUsingAlias(MessageI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(MessageI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -288,7 +284,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(MessageI18nTableMap::ID, $id, $comparison); } /** @@ -304,7 +300,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * 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 + * @return ChildMessageI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -317,7 +313,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(MessageI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -333,7 +329,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * 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 + * @return ChildMessageI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -346,7 +342,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(MessageI18nTableMap::TITLE, $title, $comparison); } /** @@ -362,7 +358,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * 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 + * @return ChildMessageI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -375,7 +371,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(MessageI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -391,7 +387,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * 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 + * @return ChildMessageI18nQuery The current query, for fluid interface */ public function filterByDescriptionHtml($descriptionHtml = null, $comparison = null) { @@ -404,32 +400,31 @@ abstract class BaseMessageI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageI18nPeer::DESCRIPTION_HTML, $descriptionHtml, $comparison); + return $this->addUsingAlias(MessageI18nTableMap::DESCRIPTION_HTML, $descriptionHtml, $comparison); } /** - * Filter the query by a related Message object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Message|ObjectCollection $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. + * @return ChildMessageI18nQuery The current query, for fluid interface */ public function filterByMessage($message, $comparison = null) { - if ($message instanceof Message) { + if ($message instanceof \Thelia\Model\Message) { return $this - ->addUsingAlias(MessageI18nPeer::ID, $message->getId(), $comparison); - } elseif ($message instanceof PropelObjectCollection) { + ->addUsingAlias(MessageI18nTableMap::ID, $message->getId(), $comparison); + } elseif ($message instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(MessageI18nPeer::ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(MessageI18nTableMap::ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByMessage() only accepts arguments of type Message or PropelCollection'); + throw new PropelException('filterByMessage() only accepts arguments of type \Thelia\Model\Message or Collection'); } } @@ -439,7 +434,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria * @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 + * @return ChildMessageI18nQuery The current query, for fluid interface */ public function joinMessage($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -468,7 +463,7 @@ abstract class BaseMessageI18nQuery extends ModelCriteria /** * Use the Message relation Message object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -486,19 +481,94 @@ abstract class BaseMessageI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param MessageI18n $messageI18n Object to remove from the list of results + * @param ChildMessageI18n $messageI18n Object to remove from the list of results * - * @return MessageI18nQuery The current query, for fluid interface + * @return ChildMessageI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(MessageI18nTableMap::ID), $messageI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(MessageI18nTableMap::LOCALE), $messageI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the message_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + MessageI18nTableMap::clearInstancePool(); + MessageI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildMessageI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildMessageI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(MessageI18nTableMap::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(); + + + MessageI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + MessageI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // MessageI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseMessageQuery.php b/core/lib/Thelia/Model/Base/MessageQuery.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseMessageQuery.php rename to core/lib/Thelia/Model/Base/MessageQuery.php index 036f52130..938a16aab --- a/core/lib/Thelia/Model/om/BaseMessageQuery.php +++ b/core/lib/Thelia/Model/Base/MessageQuery.php @@ -1,112 +1,119 @@ setModelAlias($modelAlias); } @@ -127,21 +134,21 @@ abstract class BaseMessageQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Message|Message[]|mixed the result, formatted by the current formatter + * @return ChildMessage|array|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 + if ((null !== ($obj = MessageTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(MessageTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -153,46 +160,31 @@ abstract class BaseMessageQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Message A model object, or null if the key is not found - * @throws PropelException + * @return ChildMessage A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Message(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildMessage(); $obj->hydrate($row); - MessagePeer::addInstanceToPool($obj, (string) $key); + MessageTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -203,19 +195,19 @@ abstract class BaseMessageQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Message|Message[]|mixed the result, formatted by the current formatter + * @return ChildMessage|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -224,22 +216,22 @@ abstract class BaseMessageQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Message[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -247,12 +239,12 @@ abstract class BaseMessageQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return MessageQuery The current query, for fluid interface + * @return ChildMessageQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(MessagePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(MessageTableMap::ID, $key, Criteria::EQUAL); } /** @@ -260,12 +252,12 @@ abstract class BaseMessageQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return MessageQuery The current query, for fluid interface + * @return ChildMessageQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(MessagePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(MessageTableMap::ID, $keys, Criteria::IN); } /** @@ -275,8 +267,7 @@ abstract class BaseMessageQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -285,18 +276,18 @@ abstract class BaseMessageQuery extends ModelCriteria * 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 + * @return ChildMessageQuery 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); + $this->addUsingAlias(MessageTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(MessagePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -307,7 +298,7 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::ID, $id, $comparison); + return $this->addUsingAlias(MessageTableMap::ID, $id, $comparison); } /** @@ -323,7 +314,7 @@ abstract class BaseMessageQuery extends ModelCriteria * 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 + * @return ChildMessageQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -336,7 +327,7 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::CODE, $code, $comparison); + return $this->addUsingAlias(MessageTableMap::CODE, $code, $comparison); } /** @@ -346,8 +337,7 @@ abstract class BaseMessageQuery extends ModelCriteria * * $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 + * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12 * * * @param mixed $secured The value to use as filter. @@ -356,18 +346,18 @@ abstract class BaseMessageQuery extends ModelCriteria * 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 + * @return ChildMessageQuery 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); + $this->addUsingAlias(MessageTableMap::SECURED, $secured['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($secured['max'])) { - $this->addUsingAlias(MessagePeer::SECURED, $secured['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageTableMap::SECURED, $secured['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -378,7 +368,7 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::SECURED, $secured, $comparison); + return $this->addUsingAlias(MessageTableMap::SECURED, $secured, $comparison); } /** @@ -394,7 +384,7 @@ abstract class BaseMessageQuery extends ModelCriteria * 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 + * @return ChildMessageQuery The current query, for fluid interface */ public function filterByRef($ref = null, $comparison = null) { @@ -407,7 +397,7 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::REF, $ref, $comparison); + return $this->addUsingAlias(MessageTableMap::REF, $ref, $comparison); } /** @@ -428,18 +418,18 @@ abstract class BaseMessageQuery extends ModelCriteria * 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 + * @return ChildMessageQuery 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); + $this->addUsingAlias(MessageTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(MessagePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -450,7 +440,7 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(MessageTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -471,18 +461,18 @@ abstract class BaseMessageQuery extends ModelCriteria * 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 + * @return ChildMessageQuery 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); + $this->addUsingAlias(MessageTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(MessagePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -493,7 +483,7 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(MessageTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -503,8 +493,7 @@ abstract class BaseMessageQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -513,18 +502,18 @@ abstract class BaseMessageQuery extends ModelCriteria * 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 + * @return ChildMessageQuery 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); + $this->addUsingAlias(MessageTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(MessagePeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -535,7 +524,7 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::VERSION, $version, $comparison); + return $this->addUsingAlias(MessageTableMap::VERSION, $version, $comparison); } /** @@ -556,18 +545,18 @@ abstract class BaseMessageQuery extends ModelCriteria * 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 + * @return ChildMessageQuery 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); + $this->addUsingAlias(MessageTableMap::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); + $this->addUsingAlias(MessageTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -578,7 +567,7 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(MessageTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -594,7 +583,7 @@ abstract class BaseMessageQuery extends ModelCriteria * 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 + * @return ChildMessageQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -607,30 +596,29 @@ abstract class BaseMessageQuery extends ModelCriteria } } - return $this->addUsingAlias(MessagePeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(MessageTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related MessageI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\MessageI18n|ObjectCollection $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. + * @return ChildMessageQuery The current query, for fluid interface */ public function filterByMessageI18n($messageI18n, $comparison = null) { - if ($messageI18n instanceof MessageI18n) { + if ($messageI18n instanceof \Thelia\Model\MessageI18n) { return $this - ->addUsingAlias(MessagePeer::ID, $messageI18n->getId(), $comparison); - } elseif ($messageI18n instanceof PropelObjectCollection) { + ->addUsingAlias(MessageTableMap::ID, $messageI18n->getId(), $comparison); + } elseif ($messageI18n instanceof ObjectCollection) { return $this ->useMessageI18nQuery() ->filterByPrimaryKeys($messageI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByMessageI18n() only accepts arguments of type MessageI18n or PropelCollection'); + throw new PropelException('filterByMessageI18n() only accepts arguments of type \Thelia\Model\MessageI18n or Collection'); } } @@ -640,7 +628,7 @@ abstract class BaseMessageQuery extends ModelCriteria * @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 + * @return ChildMessageQuery The current query, for fluid interface */ public function joinMessageI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -669,7 +657,7 @@ abstract class BaseMessageQuery extends ModelCriteria /** * Use the MessageI18n relation MessageI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -685,26 +673,25 @@ abstract class BaseMessageQuery extends ModelCriteria } /** - * Filter the query by a related MessageVersion object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\MessageVersion|ObjectCollection $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. + * @return ChildMessageQuery The current query, for fluid interface */ public function filterByMessageVersion($messageVersion, $comparison = null) { - if ($messageVersion instanceof MessageVersion) { + if ($messageVersion instanceof \Thelia\Model\MessageVersion) { return $this - ->addUsingAlias(MessagePeer::ID, $messageVersion->getId(), $comparison); - } elseif ($messageVersion instanceof PropelObjectCollection) { + ->addUsingAlias(MessageTableMap::ID, $messageVersion->getId(), $comparison); + } elseif ($messageVersion instanceof ObjectCollection) { return $this ->useMessageVersionQuery() ->filterByPrimaryKeys($messageVersion->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByMessageVersion() only accepts arguments of type MessageVersion or PropelCollection'); + throw new PropelException('filterByMessageVersion() only accepts arguments of type \Thelia\Model\MessageVersion or Collection'); } } @@ -714,7 +701,7 @@ abstract class BaseMessageQuery extends ModelCriteria * @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 + * @return ChildMessageQuery The current query, for fluid interface */ public function joinMessageVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -743,7 +730,7 @@ abstract class BaseMessageQuery extends ModelCriteria /** * Use the MessageVersion relation MessageVersion object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -761,19 +748,94 @@ abstract class BaseMessageQuery extends ModelCriteria /** * Exclude object from result * - * @param Message $message Object to remove from the list of results + * @param ChildMessage $message Object to remove from the list of results * - * @return MessageQuery The current query, for fluid interface + * @return ChildMessageQuery The current query, for fluid interface */ public function prune($message = null) { if ($message) { - $this->addUsingAlias(MessagePeer::ID, $message->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(MessageTableMap::ID, $message->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the message table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + MessageTableMap::clearInstancePool(); + MessageTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildMessage or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildMessage object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(MessageTableMap::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(); + + + MessageTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + MessageTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -781,31 +843,11 @@ abstract class BaseMessageQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return MessageQuery The current query, for fluid interface + * @return ChildMessageQuery 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); + return $this->addUsingAlias(MessageTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -813,32 +855,53 @@ abstract class BaseMessageQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return MessageQuery The current query, for fluid interface + * @return ChildMessageQuery 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); + return $this->addUsingAlias(MessageTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildMessageQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(MessageTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildMessageQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(MessageTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return MessageQuery The current query, for fluid interface + * @return ChildMessageQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(MessagePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(MessageTableMap::CREATED_AT); } /** * Order by create date asc * - * @return MessageQuery The current query, for fluid interface + * @return ChildMessageQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(MessagePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(MessageTableMap::CREATED_AT); } + // i18n behavior /** @@ -848,9 +911,9 @@ abstract class BaseMessageQuery extends ModelCriteria * @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 + * @return ChildMessageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'MessageI18n'; @@ -866,9 +929,9 @@ abstract class BaseMessageQuery extends ModelCriteria * @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 + * @return ChildMessageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -887,13 +950,41 @@ abstract class BaseMessageQuery extends ModelCriteria * @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 + * @return ChildMessageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'MessageI18n', 'Thelia\Model\MessageI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'MessageI18n', '\Thelia\Model\MessageI18nQuery'); } -} + // versionable behavior + + /** + * Checks whether versioning is enabled + * + * @return boolean + */ + static public function isVersioningEnabled() + { + return self::$isVersioningEnabled; + } + + /** + * Enables versioning + */ + static public function enableVersioning() + { + self::$isVersioningEnabled = true; + } + + /** + * Disables versioning + */ + static public function disableVersioning() + { + self::$isVersioningEnabled = false; + } + +} // MessageQuery diff --git a/core/lib/Thelia/Model/Base/MessageVersion.php b/core/lib/Thelia/Model/Base/MessageVersion.php new file mode 100644 index 000000000..0781a503a --- /dev/null +++ b/core/lib/Thelia/Model/Base/MessageVersion.php @@ -0,0 +1,1651 @@ +version = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\MessageVersion object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another MessageVersion instance. If + * obj is an instance of MessageVersion, delegates to + * equals(MessageVersion). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return MessageVersion The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return MessageVersion The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; + } + } + + /** + * 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 \Thelia\Model\MessageVersion The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = MessageVersionTableMap::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 \Thelia\Model\MessageVersion The current object (for fluent API support) + */ + public function setCode($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->code !== $v) { + $this->code = $v; + $this->modifiedColumns[] = MessageVersionTableMap::CODE; + } + + + return $this; + } // setCode() + + /** + * Set the value of [secured] column. + * + * @param int $v new value + * @return \Thelia\Model\MessageVersion The current object (for fluent API support) + */ + public function setSecured($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->secured !== $v) { + $this->secured = $v; + $this->modifiedColumns[] = MessageVersionTableMap::SECURED; + } + + + return $this; + } // setSecured() + + /** + * Set the value of [ref] column. + * + * @param string $v new value + * @return \Thelia\Model\MessageVersion The current object (for fluent API support) + */ + public function setRef($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->ref !== $v) { + $this->ref = $v; + $this->modifiedColumns[] = MessageVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = MessageVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = MessageVersionTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Set the value of [version] column. + * + * @param int $v new value + * @return \Thelia\Model\MessageVersion The current object (for fluent API support) + */ + public function setVersion($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->version !== $v) { + $this->version = $v; + $this->modifiedColumns[] = MessageVersionTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = MessageVersionTableMap::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 \Thelia\Model\MessageVersion The current object (for fluent API support) + */ + public function setVersionCreatedBy($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->version_created_by !== $v) { + $this->version_created_by = $v; + $this->modifiedColumns[] = MessageVersionTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MessageVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MessageVersionTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MessageVersionTableMap::translateFieldName('Secured', TableMap::TYPE_PHPNAME, $indexType)]; + $this->secured = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : MessageVersionTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : MessageVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : MessageVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : MessageVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : MessageVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : MessageVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 9; // 9 = MessageVersionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\MessageVersion object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(MessageVersionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildMessageVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aMessage = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see MessageVersion::setDeleted() + * @see MessageVersion::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildMessageVersionQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME); + } + + $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); + MessageVersionTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(MessageVersionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(MessageVersionTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; + } + if ($this->isColumnModified(MessageVersionTableMap::SECURED)) { + $modifiedColumns[':p' . $index++] = 'SECURED'; + } + if ($this->isColumnModified(MessageVersionTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; + } + if ($this->isColumnModified(MessageVersionTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(MessageVersionTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + if ($this->isColumnModified(MessageVersionTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; + } + if ($this->isColumnModified(MessageVersionTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; + } + if ($this->isColumnModified(MessageVersionTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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 ? $this->version_created_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = MessageVersionTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['MessageVersion'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['MessageVersion'][serialize($this->getPrimaryKey())] = true; + $keys = MessageVersionTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = MessageVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = MessageVersionTableMap::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(MessageVersionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(MessageVersionTableMap::ID)) $criteria->add(MessageVersionTableMap::ID, $this->id); + if ($this->isColumnModified(MessageVersionTableMap::CODE)) $criteria->add(MessageVersionTableMap::CODE, $this->code); + if ($this->isColumnModified(MessageVersionTableMap::SECURED)) $criteria->add(MessageVersionTableMap::SECURED, $this->secured); + if ($this->isColumnModified(MessageVersionTableMap::REF)) $criteria->add(MessageVersionTableMap::REF, $this->ref); + if ($this->isColumnModified(MessageVersionTableMap::CREATED_AT)) $criteria->add(MessageVersionTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(MessageVersionTableMap::UPDATED_AT)) $criteria->add(MessageVersionTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(MessageVersionTableMap::VERSION)) $criteria->add(MessageVersionTableMap::VERSION, $this->version); + if ($this->isColumnModified(MessageVersionTableMap::VERSION_CREATED_AT)) $criteria->add(MessageVersionTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(MessageVersionTableMap::VERSION_CREATED_BY)) $criteria->add(MessageVersionTableMap::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(MessageVersionTableMap::DATABASE_NAME); + $criteria->add(MessageVersionTableMap::ID, $this->id); + $criteria->add(MessageVersionTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildMessage object. + * + * @param ChildMessage $v + * @return \Thelia\Model\MessageVersion The current object (for fluent API support) + * @throws PropelException + */ + public function setMessage(ChildMessage $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 ChildMessage object, it will not be re-added. + if ($v !== null) { + $v->addMessageVersion($this); + } + + + return $this; + } + + + /** + * Get the associated ChildMessage object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildMessage The associated ChildMessage object. + * @throws PropelException + */ + public function getMessage(ConnectionInterface $con = null) + { + if ($this->aMessage === null && ($this->id !== null)) { + $this->aMessage = ChildMessageQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aMessage = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(MessageVersionTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php b/core/lib/Thelia/Model/Base/MessageVersionQuery.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseMessageVersionQuery.php rename to core/lib/Thelia/Model/Base/MessageVersionQuery.php index fc7cbec0c..ac9b0ece0 --- a/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php +++ b/core/lib/Thelia/Model/Base/MessageVersionQuery.php @@ -1,108 +1,107 @@ setModelAlias($modelAlias); } @@ -122,23 +121,22 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * $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 + * @param array[$id, $version] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return MessageVersion|MessageVersion[]|mixed the result, formatted by the current formatter + * @return ChildMessageVersion|array|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 + if ((null !== ($obj = MessageVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(MessageVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(MessageVersionTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -155,14 +153,13 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return MessageVersion A model object, or null if the key is not found - * @throws PropelException + * @return ChildMessageVersion A model object, or null if the key is not found */ 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'; + $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); @@ -170,13 +167,13 @@ abstract class BaseMessageVersionQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new MessageVersion(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildMessageVersion(); $obj->hydrate($row); - MessageVersionPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + MessageVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -187,19 +184,19 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return MessageVersion|MessageVersion[]|mixed the result, formatted by the current formatter + * @return ChildMessageVersion|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -208,22 +205,22 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|MessageVersion[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -231,12 +228,12 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return MessageVersionQuery The current query, for fluid interface + * @return ChildMessageVersionQuery 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); + $this->addUsingAlias(MessageVersionTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(MessageVersionTableMap::VERSION, $key[1], Criteria::EQUAL); return $this; } @@ -246,7 +243,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return MessageVersionQuery The current query, for fluid interface + * @return ChildMessageVersionQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -254,8 +251,8 @@ abstract class BaseMessageVersionQuery extends ModelCriteria 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 = $this->getNewCriterion(MessageVersionTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(MessageVersionTableMap::VERSION, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -270,8 +267,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByMessage() @@ -282,18 +278,18 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @return ChildMessageVersionQuery 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); + $this->addUsingAlias(MessageVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(MessageVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -304,7 +300,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageVersionPeer::ID, $id, $comparison); + return $this->addUsingAlias(MessageVersionTableMap::ID, $id, $comparison); } /** @@ -320,7 +316,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @return ChildMessageVersionQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -333,7 +329,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageVersionPeer::CODE, $code, $comparison); + return $this->addUsingAlias(MessageVersionTableMap::CODE, $code, $comparison); } /** @@ -343,8 +339,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * * $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 + * $query->filterBySecured(array('min' => 12)); // WHERE secured > 12 * * * @param mixed $secured The value to use as filter. @@ -353,18 +348,18 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @return ChildMessageVersionQuery 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); + $this->addUsingAlias(MessageVersionTableMap::SECURED, $secured['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($secured['max'])) { - $this->addUsingAlias(MessageVersionPeer::SECURED, $secured['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageVersionTableMap::SECURED, $secured['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -375,7 +370,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageVersionPeer::SECURED, $secured, $comparison); + return $this->addUsingAlias(MessageVersionTableMap::SECURED, $secured, $comparison); } /** @@ -391,7 +386,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @return ChildMessageVersionQuery The current query, for fluid interface */ public function filterByRef($ref = null, $comparison = null) { @@ -404,7 +399,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageVersionPeer::REF, $ref, $comparison); + return $this->addUsingAlias(MessageVersionTableMap::REF, $ref, $comparison); } /** @@ -425,18 +420,18 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @return ChildMessageVersionQuery 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); + $this->addUsingAlias(MessageVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(MessageVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -447,7 +442,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageVersionPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(MessageVersionTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -468,18 +463,18 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @return ChildMessageVersionQuery 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); + $this->addUsingAlias(MessageVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(MessageVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -490,7 +485,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageVersionPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(MessageVersionTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -500,8 +495,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -510,18 +504,18 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @return ChildMessageVersionQuery 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); + $this->addUsingAlias(MessageVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(MessageVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(MessageVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -532,7 +526,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageVersionPeer::VERSION, $version, $comparison); + return $this->addUsingAlias(MessageVersionTableMap::VERSION, $version, $comparison); } /** @@ -553,18 +547,18 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @return ChildMessageVersionQuery 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); + $this->addUsingAlias(MessageVersionTableMap::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); + $this->addUsingAlias(MessageVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -575,7 +569,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(MessageVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -591,7 +585,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * 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 + * @return ChildMessageVersionQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -604,32 +598,31 @@ abstract class BaseMessageVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(MessageVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(MessageVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related Message object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Message|ObjectCollection $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. + * @return ChildMessageVersionQuery The current query, for fluid interface */ public function filterByMessage($message, $comparison = null) { - if ($message instanceof Message) { + if ($message instanceof \Thelia\Model\Message) { return $this - ->addUsingAlias(MessageVersionPeer::ID, $message->getId(), $comparison); - } elseif ($message instanceof PropelObjectCollection) { + ->addUsingAlias(MessageVersionTableMap::ID, $message->getId(), $comparison); + } elseif ($message instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(MessageVersionPeer::ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(MessageVersionTableMap::ID, $message->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByMessage() only accepts arguments of type Message or PropelCollection'); + throw new PropelException('filterByMessage() only accepts arguments of type \Thelia\Model\Message or Collection'); } } @@ -639,7 +632,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria * @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 + * @return ChildMessageVersionQuery The current query, for fluid interface */ public function joinMessage($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -668,7 +661,7 @@ abstract class BaseMessageVersionQuery extends ModelCriteria /** * Use the Message relation Message object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -686,19 +679,94 @@ abstract class BaseMessageVersionQuery extends ModelCriteria /** * Exclude object from result * - * @param MessageVersion $messageVersion Object to remove from the list of results + * @param ChildMessageVersion $messageVersion Object to remove from the list of results * - * @return MessageVersionQuery The current query, for fluid interface + * @return ChildMessageVersionQuery 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->addCond('pruneCond0', $this->getAliasedColName(MessageVersionTableMap::ID), $messageVersion->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(MessageVersionTableMap::VERSION), $messageVersion->getVersion(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the message_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + MessageVersionTableMap::clearInstancePool(); + MessageVersionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildMessageVersion or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildMessageVersion object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(MessageVersionTableMap::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(); + + + MessageVersionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + MessageVersionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // MessageVersionQuery diff --git a/core/lib/Thelia/Model/om/BaseModule.php b/core/lib/Thelia/Model/Base/Module.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseModule.php rename to core/lib/Thelia/Model/Base/Module.php index e7d46a890..ebe4b4c18 --- a/core/lib/Thelia/Model/om/BaseModule.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -1,55 +1,63 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Module instance. If + * obj is an instance of Module, delegates to + * equals(Module). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Module The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Module The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [code] column value. * - * @return string + * @return string */ public function getCode() { + return $this->code; } /** * Get the [type] column value. * - * @return int + * @return int */ public function getType() { + return $this->type; } /** * Get the [activate] column value. * - * @return int + * @return int */ public function getActivate() { + return $this->activate; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -205,97 +460,57 @@ abstract class BaseModule extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Module The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = ModulePeer::ID; + $this->modifiedColumns[] = ModuleTableMap::ID; } @@ -305,18 +520,18 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Set the value of [code] column. * - * @param string $v new value - * @return Module The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Module The current object (for fluent API support) */ public function setCode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->code !== $v) { $this->code = $v; - $this->modifiedColumns[] = ModulePeer::CODE; + $this->modifiedColumns[] = ModuleTableMap::CODE; } @@ -326,18 +541,18 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Set the value of [type] column. * - * @param int $v new value - * @return Module The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Module The current object (for fluent API support) */ public function setType($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->type !== $v) { $this->type = $v; - $this->modifiedColumns[] = ModulePeer::TYPE; + $this->modifiedColumns[] = ModuleTableMap::TYPE; } @@ -347,18 +562,18 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Set the value of [activate] column. * - * @param int $v new value - * @return Module The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Module The current object (for fluent API support) */ public function setActivate($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->activate !== $v) { $this->activate = $v; - $this->modifiedColumns[] = ModulePeer::ACTIVATE; + $this->modifiedColumns[] = ModuleTableMap::ACTIVATE; } @@ -368,18 +583,18 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return Module The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Module The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = ModulePeer::POSITION; + $this->modifiedColumns[] = ModuleTableMap::POSITION; } @@ -389,19 +604,17 @@ abstract class BaseModule extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Module The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ModuleTableMap::CREATED_AT; } } // if either are not null @@ -412,19 +625,17 @@ abstract class BaseModule extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Module The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ModuleTableMap::UPDATED_AT; } } // if either are not null @@ -442,7 +653,7 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -454,23 +665,47 @@ abstract class BaseModule extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ModuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ModuleTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ModuleTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; + $this->type = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ModuleTableMap::translateFieldName('Activate', TableMap::TYPE_PHPNAME, $indexType)]; + $this->activate = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ModuleTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ModuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ModuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -478,11 +713,11 @@ abstract class BaseModule extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = ModulePeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 7; // 7 = ModuleTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Module object", $e); + throw new PropelException("Error populating \Thelia\Model\Module object", 0, $e); } } @@ -501,7 +736,6 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -509,12 +743,12 @@ abstract class BaseModule extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -525,19 +759,19 @@ abstract class BaseModule extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ModuleTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -551,26 +785,25 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Module::setDeleted() + * @see Module::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ModuleQuery::create() + $deleteQuery = ChildModuleQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -595,20 +828,19 @@ abstract class BaseModule extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -618,16 +850,16 @@ abstract class BaseModule extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(ModulePeer::CREATED_AT)) { + if (!$this->isColumnModified(ModuleTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(ModulePeer::UPDATED_AT)) { + if (!$this->isColumnModified(ModuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ModulePeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(ModuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -639,7 +871,7 @@ abstract class BaseModule extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - ModulePeer::addInstanceToPool($this); + ModuleTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -658,12 +890,12 @@ abstract class BaseModule extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -682,16 +914,15 @@ abstract class BaseModule extends BaseObject implements Persistent 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); - } + \Thelia\Model\GroupModuleQuery::create() + ->filterByPrimaryKeys($this->groupModulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->groupModulesScheduledForDeletion = null; } } - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { + if ($this->collGroupModules !== null) { + foreach ($this->collGroupModules as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -700,15 +931,15 @@ abstract class BaseModule extends BaseObject implements Persistent if ($this->moduleI18nsScheduledForDeletion !== null) { if (!$this->moduleI18nsScheduledForDeletion->isEmpty()) { - ModuleI18nQuery::create() + \Thelia\Model\ModuleI18nQuery::create() ->filterByPrimaryKeys($this->moduleI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->moduleI18nsScheduledForDeletion = null; } } - if ($this->collModuleI18ns !== null) { - foreach ($this->collModuleI18ns as $referrerFK) { + if ($this->collModuleI18ns !== null) { + foreach ($this->collModuleI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -725,46 +956,46 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = ModulePeer::ID; + $this->modifiedColumns[] = ModuleTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ModulePeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ModuleTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ModulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(ModuleTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ModulePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; + if ($this->isColumnModified(ModuleTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(ModulePeer::TYPE)) { - $modifiedColumns[':p' . $index++] = '`type`'; + if ($this->isColumnModified(ModuleTableMap::TYPE)) { + $modifiedColumns[':p' . $index++] = 'TYPE'; } - if ($this->isColumnModified(ModulePeer::ACTIVATE)) { - $modifiedColumns[':p' . $index++] = '`activate`'; + if ($this->isColumnModified(ModuleTableMap::ACTIVATE)) { + $modifiedColumns[':p' . $index++] = 'ACTIVATE'; } - if ($this->isColumnModified(ModulePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(ModuleTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(ModulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(ModuleTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(ModulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(ModuleTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `module` (%s) VALUES (%s)', + 'INSERT INTO module (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -773,39 +1004,39 @@ abstract class BaseModule extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`code`': + case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`type`': + case 'TYPE': $stmt->bindValue($identifier, $this->type, PDO::PARAM_INT); break; - case '`activate`': + case 'ACTIVATE': $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -815,120 +1046,32 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = ModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -938,7 +1081,7 @@ abstract class BaseModule extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -977,22 +1120,22 @@ abstract class BaseModule extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = ModuleTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), @@ -1002,6 +1145,12 @@ abstract class BaseModule extends BaseObject implements Persistent $keys[5] => $this->getCreatedAt(), $keys[6] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collGroupModules) { $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1017,27 +1166,27 @@ abstract class BaseModule extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = ModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1076,17 +1225,17 @@ abstract class BaseModule extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = ModulePeer::getFieldNames($keyType); + $keys = ModuleTableMap::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]]); @@ -1104,15 +1253,15 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(ModulePeer::DATABASE_NAME); + $criteria = new Criteria(ModuleTableMap::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); + if ($this->isColumnModified(ModuleTableMap::ID)) $criteria->add(ModuleTableMap::ID, $this->id); + if ($this->isColumnModified(ModuleTableMap::CODE)) $criteria->add(ModuleTableMap::CODE, $this->code); + if ($this->isColumnModified(ModuleTableMap::TYPE)) $criteria->add(ModuleTableMap::TYPE, $this->type); + if ($this->isColumnModified(ModuleTableMap::ACTIVATE)) $criteria->add(ModuleTableMap::ACTIVATE, $this->activate); + if ($this->isColumnModified(ModuleTableMap::POSITION)) $criteria->add(ModuleTableMap::POSITION, $this->position); + if ($this->isColumnModified(ModuleTableMap::CREATED_AT)) $criteria->add(ModuleTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ModuleTableMap::UPDATED_AT)) $criteria->add(ModuleTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1127,15 +1276,15 @@ abstract class BaseModule extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(ModulePeer::DATABASE_NAME); - $criteria->add(ModulePeer::ID, $this->id); + $criteria = new Criteria(ModuleTableMap::DATABASE_NAME); + $criteria->add(ModuleTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1145,7 +1294,7 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1169,9 +1318,9 @@ abstract class BaseModule extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1183,12 +1332,10 @@ abstract class BaseModule extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1202,8 +1349,6 @@ abstract class BaseModule extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1220,8 +1365,8 @@ abstract class BaseModule extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Module Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1234,40 +1379,22 @@ abstract class BaseModule extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('GroupModule' == $relationName) { - $this->initGroupModules(); + return $this->initGroupModules(); } if ('ModuleI18n' == $relationName) { - $this->initModuleI18ns(); + return $this->initModuleI18ns(); } } @@ -1277,21 +1404,16 @@ abstract class BaseModule extends BaseObject implements Persistent * This 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) + * @return void * @see addGroupModules() */ public function clearGroupModules() { - $this->collGroupModules = null; // important to set this to null since that means it is uninitialized - $this->collGroupModulesPartial = null; - - return $this; + $this->collGroupModules = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collGroupModules collection loaded partially - * - * @return void + * Reset is the collGroupModules collection loaded partially. */ public function resetPartialGroupModules($v = true) { @@ -1305,7 +1427,7 @@ abstract class BaseModule extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1315,25 +1437,25 @@ abstract class BaseModule extends BaseObject implements Persistent if (null !== $this->collGroupModules && !$overrideExisting) { return; } - $this->collGroupModules = new PropelObjectCollection(); - $this->collGroupModules->setModel('GroupModule'); + $this->collGroupModules = new ObjectCollection(); + $this->collGroupModules->setModel('\Thelia\Model\GroupModule'); } /** - * Gets an array of GroupModule objects which contain a foreign key that references this object. + * Gets an array of ChildGroupModule objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildModule is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildGroupModule[] List of ChildGroupModule objects * @throws PropelException */ - public function getGroupModules($criteria = null, PropelPDO $con = null) + public function getGroupModules($criteria = null, ConnectionInterface $con = null) { $partial = $this->collGroupModulesPartial && !$this->isNew(); if (null === $this->collGroupModules || null !== $criteria || $partial) { @@ -1341,29 +1463,31 @@ abstract class BaseModule extends BaseObject implements Persistent // return empty collection $this->initGroupModules(); } else { - $collGroupModules = GroupModuleQuery::create(null, $criteria) + $collGroupModules = ChildGroupModuleQuery::create(null, $criteria) ->filterByModule($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collGroupModulesPartial && count($collGroupModules)) { - $this->initGroupModules(false); + $this->initGroupModules(false); - foreach($collGroupModules as $obj) { - if (false == $this->collGroupModules->contains($obj)) { - $this->collGroupModules->append($obj); + foreach ($collGroupModules as $obj) { + if (false == $this->collGroupModules->contains($obj)) { + $this->collGroupModules->append($obj); + } } - } - $this->collGroupModulesPartial = true; + $this->collGroupModulesPartial = true; } $collGroupModules->getInternalIterator()->rewind(); + return $collGroupModules; } - if($partial && $this->collGroupModules) { - foreach($this->collGroupModules as $obj) { - if($obj->isNew()) { + if ($partial && $this->collGroupModules) { + foreach ($this->collGroupModules as $obj) { + if ($obj->isNew()) { $collGroupModules[] = $obj; } } @@ -1383,15 +1507,16 @@ abstract class BaseModule extends BaseObject implements Persistent * It will 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) + * @param Collection $groupModules A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) */ - public function setGroupModules(PropelCollection $groupModules, PropelPDO $con = null) + public function setGroupModules(Collection $groupModules, ConnectionInterface $con = null) { $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); - $this->groupModulesScheduledForDeletion = unserialize(serialize($groupModulesToDelete)); + + $this->groupModulesScheduledForDeletion = $groupModulesToDelete; foreach ($groupModulesToDelete as $groupModuleRemoved) { $groupModuleRemoved->setModule(null); @@ -1411,13 +1536,13 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Returns the number of related GroupModule objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related GroupModule objects. * @throws PropelException */ - public function countGroupModules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countGroupModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collGroupModulesPartial && !$this->isNew(); if (null === $this->collGroupModules || null !== $criteria || $partial) { @@ -1425,10 +1550,11 @@ abstract class BaseModule extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getGroupModules()); } - $query = GroupModuleQuery::create(null, $criteria); + + $query = ChildGroupModuleQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1442,18 +1568,19 @@ abstract class BaseModule extends BaseObject implements Persistent } /** - * Method called to associate a GroupModule object to this object - * through the GroupModule foreign key attribute. + * Method called to associate a ChildGroupModule object to this object + * through the ChildGroupModule foreign key attribute. * - * @param GroupModule $l GroupModule - * @return Module The current object (for fluent API support) + * @param ChildGroupModule $l ChildGroupModule + * @return \Thelia\Model\Module The current object (for fluent API support) */ - public function addGroupModule(GroupModule $l) + public function addGroupModule(ChildGroupModule $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); } @@ -1462,7 +1589,7 @@ abstract class BaseModule extends BaseObject implements Persistent } /** - * @param GroupModule $groupModule The groupModule object to add. + * @param GroupModule $groupModule The groupModule object to add. */ protected function doAddGroupModule($groupModule) { @@ -1471,8 +1598,8 @@ abstract class BaseModule extends BaseObject implements Persistent } /** - * @param GroupModule $groupModule The groupModule object to remove. - * @return Module The current object (for fluent API support) + * @param GroupModule $groupModule The groupModule object to remove. + * @return ChildModule The current object (for fluent API support) */ public function removeGroupModule($groupModule) { @@ -1501,15 +1628,15 @@ abstract class BaseModule extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildGroupModule[] List of ChildGroupModule objects */ - public function getGroupModulesJoinGroup($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getGroupModulesJoinGroup($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = GroupModuleQuery::create(null, $criteria); - $query->joinWith('Group', $join_behavior); + $query = ChildGroupModuleQuery::create(null, $criteria); + $query->joinWith('Group', $joinBehavior); return $this->getGroupModules($query, $con); } @@ -1520,21 +1647,16 @@ abstract class BaseModule extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collModuleI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collModuleI18ns collection loaded partially - * - * @return void + * Reset is the collModuleI18ns collection loaded partially. */ public function resetPartialModuleI18ns($v = true) { @@ -1548,7 +1670,7 @@ abstract class BaseModule extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1558,25 +1680,25 @@ abstract class BaseModule extends BaseObject implements Persistent if (null !== $this->collModuleI18ns && !$overrideExisting) { return; } - $this->collModuleI18ns = new PropelObjectCollection(); - $this->collModuleI18ns->setModel('ModuleI18n'); + $this->collModuleI18ns = new ObjectCollection(); + $this->collModuleI18ns->setModel('\Thelia\Model\ModuleI18n'); } /** - * Gets an array of ModuleI18n objects which contain a foreign key that references this object. + * Gets an array of ChildModuleI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildModule is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildModuleI18n[] List of ChildModuleI18n objects * @throws PropelException */ - public function getModuleI18ns($criteria = null, PropelPDO $con = null) + public function getModuleI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collModuleI18nsPartial && !$this->isNew(); if (null === $this->collModuleI18ns || null !== $criteria || $partial) { @@ -1584,29 +1706,31 @@ abstract class BaseModule extends BaseObject implements Persistent // return empty collection $this->initModuleI18ns(); } else { - $collModuleI18ns = ModuleI18nQuery::create(null, $criteria) + $collModuleI18ns = ChildModuleI18nQuery::create(null, $criteria) ->filterByModule($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collModuleI18nsPartial && count($collModuleI18ns)) { - $this->initModuleI18ns(false); + $this->initModuleI18ns(false); - foreach($collModuleI18ns as $obj) { - if (false == $this->collModuleI18ns->contains($obj)) { - $this->collModuleI18ns->append($obj); + foreach ($collModuleI18ns as $obj) { + if (false == $this->collModuleI18ns->contains($obj)) { + $this->collModuleI18ns->append($obj); + } } - } - $this->collModuleI18nsPartial = true; + $this->collModuleI18nsPartial = true; } $collModuleI18ns->getInternalIterator()->rewind(); + return $collModuleI18ns; } - if($partial && $this->collModuleI18ns) { - foreach($this->collModuleI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collModuleI18ns) { + foreach ($this->collModuleI18ns as $obj) { + if ($obj->isNew()) { $collModuleI18ns[] = $obj; } } @@ -1626,15 +1750,19 @@ abstract class BaseModule extends BaseObject implements Persistent * It will 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) + * @param Collection $moduleI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) */ - public function setModuleI18ns(PropelCollection $moduleI18ns, PropelPDO $con = null) + public function setModuleI18ns(Collection $moduleI18ns, ConnectionInterface $con = null) { $moduleI18nsToDelete = $this->getModuleI18ns(new Criteria(), $con)->diff($moduleI18ns); - $this->moduleI18nsScheduledForDeletion = unserialize(serialize($moduleI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->moduleI18nsScheduledForDeletion = clone $moduleI18nsToDelete; foreach ($moduleI18nsToDelete as $moduleI18nRemoved) { $moduleI18nRemoved->setModule(null); @@ -1654,13 +1782,13 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Returns the number of related ModuleI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ModuleI18n objects. * @throws PropelException */ - public function countModuleI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countModuleI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collModuleI18nsPartial && !$this->isNew(); if (null === $this->collModuleI18ns || null !== $criteria || $partial) { @@ -1668,10 +1796,11 @@ abstract class BaseModule extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getModuleI18ns()); } - $query = ModuleI18nQuery::create(null, $criteria); + + $query = ChildModuleI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1685,13 +1814,13 @@ abstract class BaseModule extends BaseObject implements Persistent } /** - * Method called to associate a ModuleI18n object to this object - * through the ModuleI18n foreign key attribute. + * Method called to associate a ChildModuleI18n object to this object + * through the ChildModuleI18n foreign key attribute. * - * @param ModuleI18n $l ModuleI18n - * @return Module The current object (for fluent API support) + * @param ChildModuleI18n $l ChildModuleI18n + * @return \Thelia\Model\Module The current object (for fluent API support) */ - public function addModuleI18n(ModuleI18n $l) + public function addModuleI18n(ChildModuleI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1701,6 +1830,7 @@ abstract class BaseModule extends BaseObject implements Persistent $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); } @@ -1709,7 +1839,7 @@ abstract class BaseModule extends BaseObject implements Persistent } /** - * @param ModuleI18n $moduleI18n The moduleI18n object to add. + * @param ModuleI18n $moduleI18n The moduleI18n object to add. */ protected function doAddModuleI18n($moduleI18n) { @@ -1718,8 +1848,8 @@ abstract class BaseModule extends BaseObject implements Persistent } /** - * @param ModuleI18n $moduleI18n The moduleI18n object to remove. - * @return Module The current object (for fluent API support) + * @param ModuleI18n $moduleI18n The moduleI18n object to remove. + * @return ChildModule The current object (for fluent API support) */ public function removeModuleI18n($moduleI18n) { @@ -1749,8 +1879,6 @@ abstract class BaseModule extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1762,14 +1890,13 @@ abstract class BaseModule extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collGroupModules) { foreach ($this->collGroupModules as $o) { $o->clearAllReferences($deep); @@ -1780,42 +1907,30 @@ abstract class BaseModule extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collGroupModules instanceof PropelCollection) { + if ($this->collGroupModules instanceof Collection) { $this->collGroupModules->clearIterator(); } $this->collGroupModules = null; - if ($this->collModuleI18ns instanceof PropelCollection) { + if ($this->collModuleI18ns instanceof Collection) { $this->collModuleI18ns->clearIterator(); } $this->collModuleI18ns = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(ModuleTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1823,11 +1938,11 @@ abstract class BaseModule extends BaseObject implements Persistent /** * 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) + * @return ChildModule The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = ModulePeer::UPDATED_AT; + $this->modifiedColumns[] = ModuleTableMap::UPDATED_AT; return $this; } @@ -1839,9 +1954,9 @@ abstract class BaseModule extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Module The current object (for fluent API support) + * @return ChildModule The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1862,10 +1977,10 @@ abstract class BaseModule extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return ModuleI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildModuleI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collModuleI18ns) { @@ -1878,10 +1993,10 @@ abstract class BaseModule extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new ModuleI18n(); + $translation = new ChildModuleI18n(); $translation->setLocale($locale); } else { - $translation = ModuleI18nQuery::create() + $translation = ChildModuleI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -1896,14 +2011,14 @@ abstract class BaseModule extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Module The current object (for fluent API support) + * @return ChildModule The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - ModuleI18nQuery::create() + ChildModuleI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -1923,10 +2038,10 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return ModuleI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildModuleI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -1935,7 +2050,7 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -1946,8 +2061,8 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ModuleI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -1959,7 +2074,7 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -1970,8 +2085,8 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ModuleI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -1983,7 +2098,7 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -1994,8 +2109,8 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ModuleI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2007,7 +2122,7 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -2018,8 +2133,8 @@ abstract class BaseModule extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ModuleI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -2027,4 +2142,122 @@ abstract class BaseModule extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/ModuleI18n.php b/core/lib/Thelia/Model/Base/ModuleI18n.php new file mode 100644 index 000000000..54cf305e4 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ModuleI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ModuleI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ModuleI18n instance. If + * obj is an instance of ModuleI18n, delegates to + * equals(ModuleI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ModuleI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ModuleI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\ModuleI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ModuleI18nTableMap::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 \Thelia\Model\ModuleI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ModuleI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ModuleI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ModuleI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ModuleI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ModuleI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ModuleI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ModuleI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ModuleI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ModuleI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ModuleI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ModuleI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ModuleI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ModuleI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ModuleI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ModuleI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildModuleI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aModule = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ModuleI18n::setDeleted() + * @see ModuleI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildModuleI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME); + } + + $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); + ModuleI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ModuleI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ModuleI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ModuleI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ModuleI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ModuleI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ModuleI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ModuleI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ModuleI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ModuleI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ModuleI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ModuleI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ModuleI18nTableMap::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(ModuleI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ModuleI18nTableMap::ID)) $criteria->add(ModuleI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ModuleI18nTableMap::LOCALE)) $criteria->add(ModuleI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ModuleI18nTableMap::TITLE)) $criteria->add(ModuleI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ModuleI18nTableMap::DESCRIPTION)) $criteria->add(ModuleI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ModuleI18nTableMap::CHAPO)) $criteria->add(ModuleI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ModuleI18nTableMap::POSTSCRIPTUM)) $criteria->add(ModuleI18nTableMap::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(ModuleI18nTableMap::DATABASE_NAME); + $criteria->add(ModuleI18nTableMap::ID, $this->id); + $criteria->add(ModuleI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\ModuleI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setModule(ChildModule $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 ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addModuleI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModule(ConnectionInterface $con = null) + { + if ($this->aModule === null && ($this->id !== null)) { + $this->aModule = ChildModuleQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aModule = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ModuleI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseModuleI18nQuery.php b/core/lib/Thelia/Model/Base/ModuleI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseModuleI18nQuery.php rename to core/lib/Thelia/Model/Base/ModuleI18nQuery.php index ca75f0050..d3d4694fb --- a/core/lib/Thelia/Model/om/BaseModuleI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ModuleI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ModuleI18n|ModuleI18n[]|mixed the result, formatted by the current formatter + * @return ChildModuleI18n|array|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 + if ((null !== ($obj = ModuleI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ModuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ModuleI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ModuleI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildModuleI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `module_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseModuleI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ModuleI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildModuleI18n(); $obj->hydrate($row); - ModuleI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ModuleI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ModuleI18n|ModuleI18n[]|mixed the result, formatted by the current formatter + * @return ChildModuleI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ModuleI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ModuleI18nQuery The current query, for fluid interface + * @return ChildModuleI18nQuery 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); + $this->addUsingAlias(ModuleI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ModuleI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ModuleI18nQuery The current query, for fluid interface + * @return ChildModuleI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseModuleI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(ModuleI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ModuleI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByModule() @@ -270,18 +266,18 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * 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 + * @return ChildModuleI18nQuery 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); + $this->addUsingAlias(ModuleI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ModuleI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ModuleI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ModuleI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(ModuleI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * 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 + * @return ChildModuleI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ModuleI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(ModuleI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * 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 + * @return ChildModuleI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ModuleI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(ModuleI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * 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 + * @return ChildModuleI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ModuleI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(ModuleI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * 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 + * @return ChildModuleI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ModuleI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(ModuleI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * 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 + * @return ChildModuleI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseModuleI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ModuleI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(ModuleI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Module object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Module|ObjectCollection $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. + * @return ChildModuleI18nQuery The current query, for fluid interface */ public function filterByModule($module, $comparison = null) { - if ($module instanceof Module) { + if ($module instanceof \Thelia\Model\Module) { return $this - ->addUsingAlias(ModuleI18nPeer::ID, $module->getId(), $comparison); - } elseif ($module instanceof PropelObjectCollection) { + ->addUsingAlias(ModuleI18nTableMap::ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ModuleI18nPeer::ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ModuleI18nTableMap::ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByModule() only accepts arguments of type Module or PropelCollection'); + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria * @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 + * @return ChildModuleI18nQuery The current query, for fluid interface */ public function joinModule($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseModuleI18nQuery extends ModelCriteria /** * Use the Module relation Module object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseModuleI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param ModuleI18n $moduleI18n Object to remove from the list of results + * @param ChildModuleI18n $moduleI18n Object to remove from the list of results * - * @return ModuleI18nQuery The current query, for fluid interface + * @return ChildModuleI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(ModuleI18nTableMap::ID), $moduleI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ModuleI18nTableMap::LOCALE), $moduleI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the module_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ModuleI18nTableMap::clearInstancePool(); + ModuleI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildModuleI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildModuleI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ModuleI18nTableMap::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(); + + + ModuleI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ModuleI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ModuleI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php old mode 100755 new mode 100644 similarity index 56% rename from core/lib/Thelia/Model/om/BaseModuleQuery.php rename to core/lib/Thelia/Model/Base/ModuleQuery.php index 66b9225c7..7db21ca22 --- a/core/lib/Thelia/Model/om/BaseModuleQuery.php +++ b/core/lib/Thelia/Model/Base/ModuleQuery.php @@ -1,104 +1,104 @@ setModelAlias($modelAlias); } @@ -119,21 +119,21 @@ abstract class BaseModuleQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Module|Module[]|mixed the result, formatted by the current formatter + * @return ChildModule|array|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 + if ((null !== ($obj = ModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ModuleTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -145,46 +145,31 @@ abstract class BaseModuleQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Module A model object, or null if the key is not found - * @throws PropelException + * @return ChildModule A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `code`, `type`, `activate`, `position`, `created_at`, `updated_at` FROM `module` WHERE `id` = :p0'; + $sql = 'SELECT ID, CODE, TYPE, ACTIVATE, POSITION, CREATED_AT, UPDATED_AT FROM module WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Module(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildModule(); $obj->hydrate($row); - ModulePeer::addInstanceToPool($obj, (string) $key); + ModuleTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -195,19 +180,19 @@ abstract class BaseModuleQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Module|Module[]|mixed the result, formatted by the current formatter + * @return ChildModule|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -216,22 +201,22 @@ abstract class BaseModuleQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Module[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -239,12 +224,12 @@ abstract class BaseModuleQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ModuleQuery The current query, for fluid interface + * @return ChildModuleQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(ModulePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(ModuleTableMap::ID, $key, Criteria::EQUAL); } /** @@ -252,12 +237,12 @@ abstract class BaseModuleQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ModuleQuery The current query, for fluid interface + * @return ChildModuleQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(ModulePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(ModuleTableMap::ID, $keys, Criteria::IN); } /** @@ -267,8 +252,7 @@ abstract class BaseModuleQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -277,18 +261,18 @@ abstract class BaseModuleQuery extends ModelCriteria * 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 + * @return ChildModuleQuery 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); + $this->addUsingAlias(ModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ModulePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -299,7 +283,7 @@ abstract class BaseModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(ModulePeer::ID, $id, $comparison); + return $this->addUsingAlias(ModuleTableMap::ID, $id, $comparison); } /** @@ -315,7 +299,7 @@ abstract class BaseModuleQuery extends ModelCriteria * 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 + * @return ChildModuleQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -328,7 +312,7 @@ abstract class BaseModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(ModulePeer::CODE, $code, $comparison); + return $this->addUsingAlias(ModuleTableMap::CODE, $code, $comparison); } /** @@ -338,8 +322,7 @@ abstract class BaseModuleQuery extends ModelCriteria * * $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 + * $query->filterByType(array('min' => 12)); // WHERE type > 12 * * * @param mixed $type The value to use as filter. @@ -348,18 +331,18 @@ abstract class BaseModuleQuery extends ModelCriteria * 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 + * @return ChildModuleQuery 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); + $this->addUsingAlias(ModuleTableMap::TYPE, $type['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($type['max'])) { - $this->addUsingAlias(ModulePeer::TYPE, $type['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ModuleTableMap::TYPE, $type['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -370,7 +353,7 @@ abstract class BaseModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(ModulePeer::TYPE, $type, $comparison); + return $this->addUsingAlias(ModuleTableMap::TYPE, $type, $comparison); } /** @@ -380,8 +363,7 @@ abstract class BaseModuleQuery extends ModelCriteria * * $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 + * $query->filterByActivate(array('min' => 12)); // WHERE activate > 12 * * * @param mixed $activate The value to use as filter. @@ -390,18 +372,18 @@ abstract class BaseModuleQuery extends ModelCriteria * 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 + * @return ChildModuleQuery 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); + $this->addUsingAlias(ModuleTableMap::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($activate['max'])) { - $this->addUsingAlias(ModulePeer::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ModuleTableMap::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -412,7 +394,7 @@ abstract class BaseModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(ModulePeer::ACTIVATE, $activate, $comparison); + return $this->addUsingAlias(ModuleTableMap::ACTIVATE, $activate, $comparison); } /** @@ -422,8 +404,7 @@ abstract class BaseModuleQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -432,18 +413,18 @@ abstract class BaseModuleQuery extends ModelCriteria * 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 + * @return ChildModuleQuery 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); + $this->addUsingAlias(ModuleTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(ModulePeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ModuleTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -454,7 +435,7 @@ abstract class BaseModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(ModulePeer::POSITION, $position, $comparison); + return $this->addUsingAlias(ModuleTableMap::POSITION, $position, $comparison); } /** @@ -475,18 +456,18 @@ abstract class BaseModuleQuery extends ModelCriteria * 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 + * @return ChildModuleQuery 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); + $this->addUsingAlias(ModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ModulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -497,7 +478,7 @@ abstract class BaseModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(ModulePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ModuleTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -518,18 +499,18 @@ abstract class BaseModuleQuery extends ModelCriteria * 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 + * @return ChildModuleQuery 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); + $this->addUsingAlias(ModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ModulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -540,30 +521,29 @@ abstract class BaseModuleQuery extends ModelCriteria } } - return $this->addUsingAlias(ModulePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ModuleTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related GroupModule object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\GroupModule|ObjectCollection $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. + * @return ChildModuleQuery The current query, for fluid interface */ public function filterByGroupModule($groupModule, $comparison = null) { - if ($groupModule instanceof GroupModule) { + if ($groupModule instanceof \Thelia\Model\GroupModule) { return $this - ->addUsingAlias(ModulePeer::ID, $groupModule->getModuleId(), $comparison); - } elseif ($groupModule instanceof PropelObjectCollection) { + ->addUsingAlias(ModuleTableMap::ID, $groupModule->getModuleId(), $comparison); + } elseif ($groupModule instanceof ObjectCollection) { return $this ->useGroupModuleQuery() ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection'); + throw new PropelException('filterByGroupModule() only accepts arguments of type \Thelia\Model\GroupModule or Collection'); } } @@ -573,7 +553,7 @@ abstract class BaseModuleQuery extends ModelCriteria * @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 + * @return ChildModuleQuery The current query, for fluid interface */ public function joinGroupModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -602,7 +582,7 @@ abstract class BaseModuleQuery extends ModelCriteria /** * Use the GroupModule relation GroupModule object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -618,26 +598,25 @@ abstract class BaseModuleQuery extends ModelCriteria } /** - * Filter the query by a related ModuleI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ModuleI18n|ObjectCollection $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. + * @return ChildModuleQuery The current query, for fluid interface */ public function filterByModuleI18n($moduleI18n, $comparison = null) { - if ($moduleI18n instanceof ModuleI18n) { + if ($moduleI18n instanceof \Thelia\Model\ModuleI18n) { return $this - ->addUsingAlias(ModulePeer::ID, $moduleI18n->getId(), $comparison); - } elseif ($moduleI18n instanceof PropelObjectCollection) { + ->addUsingAlias(ModuleTableMap::ID, $moduleI18n->getId(), $comparison); + } elseif ($moduleI18n instanceof ObjectCollection) { return $this ->useModuleI18nQuery() ->filterByPrimaryKeys($moduleI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByModuleI18n() only accepts arguments of type ModuleI18n or PropelCollection'); + throw new PropelException('filterByModuleI18n() only accepts arguments of type \Thelia\Model\ModuleI18n or Collection'); } } @@ -647,7 +626,7 @@ abstract class BaseModuleQuery extends ModelCriteria * @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 + * @return ChildModuleQuery The current query, for fluid interface */ public function joinModuleI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -676,7 +655,7 @@ abstract class BaseModuleQuery extends ModelCriteria /** * Use the ModuleI18n relation ModuleI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -694,19 +673,94 @@ abstract class BaseModuleQuery extends ModelCriteria /** * Exclude object from result * - * @param Module $module Object to remove from the list of results + * @param ChildModule $module Object to remove from the list of results * - * @return ModuleQuery The current query, for fluid interface + * @return ChildModuleQuery The current query, for fluid interface */ public function prune($module = null) { if ($module) { - $this->addUsingAlias(ModulePeer::ID, $module->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(ModuleTableMap::ID, $module->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the module table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ModuleTableMap::clearInstancePool(); + ModuleTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildModule or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildModule object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ModuleTableMap::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(); + + + ModuleTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ModuleTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -714,31 +768,11 @@ abstract class BaseModuleQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ModuleQuery The current query, for fluid interface + * @return ChildModuleQuery 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); + return $this->addUsingAlias(ModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -746,32 +780,53 @@ abstract class BaseModuleQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ModuleQuery The current query, for fluid interface + * @return ChildModuleQuery 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); + return $this->addUsingAlias(ModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ModuleTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ModuleTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ModuleQuery The current query, for fluid interface + * @return ChildModuleQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(ModulePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(ModuleTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ModuleQuery The current query, for fluid interface + * @return ChildModuleQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(ModulePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(ModuleTableMap::CREATED_AT); } + // i18n behavior /** @@ -781,9 +836,9 @@ abstract class BaseModuleQuery extends ModelCriteria * @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 + * @return ChildModuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ModuleI18n'; @@ -799,9 +854,9 @@ abstract class BaseModuleQuery extends ModelCriteria * @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 + * @return ChildModuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -820,13 +875,13 @@ abstract class BaseModuleQuery extends ModelCriteria * @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 + * @return ChildModuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ModuleI18n', 'Thelia\Model\ModuleI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'ModuleI18n', '\Thelia\Model\ModuleI18nQuery'); } -} +} // ModuleQuery diff --git a/core/lib/Thelia/Model/om/BaseOrder.php b/core/lib/Thelia/Model/Base/Order.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseOrder.php rename to core/lib/Thelia/Model/Base/Order.php index 9f3c72e34..b815aff34 --- a/core/lib/Thelia/Model/om/BaseOrder.php +++ b/core/lib/Thelia/Model/Base/Order.php @@ -1,63 +1,71 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Order instance. If + * obj is an instance of Order, delegates to + * equals(Order). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Order The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Order The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [ref] column value. * - * @return string + * @return string */ public function getRef() { + return $this->ref; } /** * Get the [customer_id] column value. * - * @return int + * @return int */ public function getCustomerId() { + return $this->customer_id; } /** * Get the [address_invoice] column value. * - * @return int + * @return int */ public function getAddressInvoice() { + return $this->address_invoice; } /** * Get the [address_delivery] column value. * - * @return int + * @return int */ public function getAddressDelivery() { + return $this->address_delivery; } @@ -290,139 +545,129 @@ abstract class BaseOrder extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time 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') + public function getInvoiceDate($format = NULL) { - 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; + return $this->invoice_date; + } else { + return $this->invoice_date !== null ? $this->invoice_date->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [currency_id] column value. * - * @return int + * @return int */ public function getCurrencyId() { + return $this->currency_id; } /** * Get the [currency_rate] column value. * - * @return double + * @return double */ public function getCurrencyRate() { + return $this->currency_rate; } /** * Get the [transaction] column value. * - * @return string + * @return string */ public function getTransaction() { + return $this->transaction; } /** * Get the [delivery_num] column value. * - * @return string + * @return string */ public function getDeliveryNum() { + return $this->delivery_num; } /** * Get the [invoice] column value. * - * @return string + * @return string */ public function getInvoice() { + return $this->invoice; } /** * Get the [postage] column value. * - * @return double + * @return double */ public function getPostage() { + return $this->postage; } /** * Get the [payment] column value. * - * @return string + * @return string */ public function getPayment() { + return $this->payment; } /** * Get the [carrier] column value. * - * @return string + * @return string */ public function getCarrier() { + return $this->carrier; } /** * Get the [status_id] column value. * - * @return int + * @return int */ public function getStatusId() { + return $this->status_id; } /** * Get the [lang] column value. * - * @return string + * @return string */ public function getLang() { + return $this->lang; } @@ -430,97 +675,57 @@ abstract class BaseOrder extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = OrderPeer::ID; + $this->modifiedColumns[] = OrderTableMap::ID; } @@ -530,18 +735,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [ref] column. * - * @param string $v new value - * @return Order The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setRef($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->ref !== $v) { $this->ref = $v; - $this->modifiedColumns[] = OrderPeer::REF; + $this->modifiedColumns[] = OrderTableMap::REF; } @@ -551,18 +756,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [customer_id] column. * - * @param int $v new value - * @return Order The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setCustomerId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->customer_id !== $v) { $this->customer_id = $v; - $this->modifiedColumns[] = OrderPeer::CUSTOMER_ID; + $this->modifiedColumns[] = OrderTableMap::CUSTOMER_ID; } if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) { @@ -576,18 +781,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [address_invoice] column. * - * @param int $v new value - * @return Order The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setAddressInvoice($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->address_invoice !== $v) { $this->address_invoice = $v; - $this->modifiedColumns[] = OrderPeer::ADDRESS_INVOICE; + $this->modifiedColumns[] = OrderTableMap::ADDRESS_INVOICE; } if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->aOrderAddressRelatedByAddressInvoice->getId() !== $v) { @@ -601,18 +806,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [address_delivery] column. * - * @param int $v new value - * @return Order The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setAddressDelivery($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->address_delivery !== $v) { $this->address_delivery = $v; - $this->modifiedColumns[] = OrderPeer::ADDRESS_DELIVERY; + $this->modifiedColumns[] = OrderTableMap::ADDRESS_DELIVERY; } if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->aOrderAddressRelatedByAddressDelivery->getId() !== $v) { @@ -626,19 +831,17 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setInvoiceDate($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->invoice_date) { + $this->invoice_date = $dt; + $this->modifiedColumns[] = OrderTableMap::INVOICE_DATE; } } // if either are not null @@ -649,18 +852,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [currency_id] column. * - * @param int $v new value - * @return Order The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setCurrencyId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->currency_id !== $v) { $this->currency_id = $v; - $this->modifiedColumns[] = OrderPeer::CURRENCY_ID; + $this->modifiedColumns[] = OrderTableMap::CURRENCY_ID; } if ($this->aCurrency !== null && $this->aCurrency->getId() !== $v) { @@ -674,18 +877,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [currency_rate] column. * - * @param double $v new value - * @return Order The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setCurrencyRate($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->currency_rate !== $v) { $this->currency_rate = $v; - $this->modifiedColumns[] = OrderPeer::CURRENCY_RATE; + $this->modifiedColumns[] = OrderTableMap::CURRENCY_RATE; } @@ -695,18 +898,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [transaction] column. * - * @param string $v new value - * @return Order The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setTransaction($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->transaction !== $v) { $this->transaction = $v; - $this->modifiedColumns[] = OrderPeer::TRANSACTION; + $this->modifiedColumns[] = OrderTableMap::TRANSACTION; } @@ -716,18 +919,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [delivery_num] column. * - * @param string $v new value - * @return Order The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setDeliveryNum($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->delivery_num !== $v) { $this->delivery_num = $v; - $this->modifiedColumns[] = OrderPeer::DELIVERY_NUM; + $this->modifiedColumns[] = OrderTableMap::DELIVERY_NUM; } @@ -737,18 +940,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [invoice] column. * - * @param string $v new value - * @return Order The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setInvoice($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->invoice !== $v) { $this->invoice = $v; - $this->modifiedColumns[] = OrderPeer::INVOICE; + $this->modifiedColumns[] = OrderTableMap::INVOICE; } @@ -758,18 +961,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [postage] column. * - * @param double $v new value - * @return Order The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setPostage($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->postage !== $v) { $this->postage = $v; - $this->modifiedColumns[] = OrderPeer::POSTAGE; + $this->modifiedColumns[] = OrderTableMap::POSTAGE; } @@ -779,18 +982,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [payment] column. * - * @param string $v new value - * @return Order The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setPayment($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->payment !== $v) { $this->payment = $v; - $this->modifiedColumns[] = OrderPeer::PAYMENT; + $this->modifiedColumns[] = OrderTableMap::PAYMENT; } @@ -800,18 +1003,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [carrier] column. * - * @param string $v new value - * @return Order The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setCarrier($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->carrier !== $v) { $this->carrier = $v; - $this->modifiedColumns[] = OrderPeer::CARRIER; + $this->modifiedColumns[] = OrderTableMap::CARRIER; } @@ -821,18 +1024,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [status_id] column. * - * @param int $v new value - * @return Order The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setStatusId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->status_id !== $v) { $this->status_id = $v; - $this->modifiedColumns[] = OrderPeer::STATUS_ID; + $this->modifiedColumns[] = OrderTableMap::STATUS_ID; } if ($this->aOrderStatus !== null && $this->aOrderStatus->getId() !== $v) { @@ -846,18 +1049,18 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Set the value of [lang] column. * - * @param string $v new value - * @return Order The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setLang($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->lang !== $v) { $this->lang = $v; - $this->modifiedColumns[] = OrderPeer::LANG; + $this->modifiedColumns[] = OrderTableMap::LANG; } @@ -867,19 +1070,17 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderTableMap::CREATED_AT; } } // if either are not null @@ -890,19 +1091,17 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Order The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderTableMap::UPDATED_AT; } } // if either are not null @@ -920,7 +1119,7 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -932,34 +1131,83 @@ abstract class BaseOrder extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->customer_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderTableMap::translateFieldName('AddressInvoice', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address_invoice = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderTableMap::translateFieldName('AddressDelivery', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address_delivery = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderTableMap::translateFieldName('InvoiceDate', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00') { + $col = null; + } + $this->invoice_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderTableMap::translateFieldName('CurrencyId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->currency_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderTableMap::translateFieldName('CurrencyRate', TableMap::TYPE_PHPNAME, $indexType)]; + $this->currency_rate = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderTableMap::translateFieldName('Transaction', TableMap::TYPE_PHPNAME, $indexType)]; + $this->transaction = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderTableMap::translateFieldName('DeliveryNum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_num = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderTableMap::translateFieldName('Invoice', TableMap::TYPE_PHPNAME, $indexType)]; + $this->invoice = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderTableMap::translateFieldName('Postage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postage = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderTableMap::translateFieldName('Payment', TableMap::TYPE_PHPNAME, $indexType)]; + $this->payment = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderTableMap::translateFieldName('Carrier', TableMap::TYPE_PHPNAME, $indexType)]; + $this->carrier = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderTableMap::translateFieldName('StatusId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->status_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderTableMap::translateFieldName('Lang', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lang = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : OrderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -967,11 +1215,11 @@ abstract class BaseOrder extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 18; // 18 = OrderPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 18; // 18 = OrderTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Order object", $e); + throw new PropelException("Error populating \Thelia\Model\Order object", 0, $e); } } @@ -990,7 +1238,6 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) { $this->aCustomer = null; } @@ -1013,12 +1260,12 @@ abstract class BaseOrder extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -1029,19 +1276,19 @@ abstract class BaseOrder extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(OrderTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildOrderQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -1060,26 +1307,25 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Order::setDeleted() + * @see Order::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = OrderQuery::create() + $deleteQuery = ChildOrderQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -1104,20 +1350,19 @@ abstract class BaseOrder extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -1127,16 +1372,16 @@ abstract class BaseOrder extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(OrderPeer::CREATED_AT)) { + if (!$this->isColumnModified(OrderTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(OrderPeer::UPDATED_AT)) { + if (!$this->isColumnModified(OrderTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(OrderTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -1148,7 +1393,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - OrderPeer::addInstanceToPool($this); + OrderTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1167,19 +1412,19 @@ abstract class BaseOrder extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -1231,15 +1476,15 @@ abstract class BaseOrder extends BaseObject implements Persistent if ($this->orderProductsScheduledForDeletion !== null) { if (!$this->orderProductsScheduledForDeletion->isEmpty()) { - OrderProductQuery::create() + \Thelia\Model\OrderProductQuery::create() ->filterByPrimaryKeys($this->orderProductsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->orderProductsScheduledForDeletion = null; } } - if ($this->collOrderProducts !== null) { - foreach ($this->collOrderProducts as $referrerFK) { + if ($this->collOrderProducts !== null) { + foreach ($this->collOrderProducts as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1248,15 +1493,15 @@ abstract class BaseOrder extends BaseObject implements Persistent if ($this->couponOrdersScheduledForDeletion !== null) { if (!$this->couponOrdersScheduledForDeletion->isEmpty()) { - CouponOrderQuery::create() + \Thelia\Model\CouponOrderQuery::create() ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->couponOrdersScheduledForDeletion = null; } } - if ($this->collCouponOrders !== null) { - foreach ($this->collCouponOrders as $referrerFK) { + if ($this->collCouponOrders !== null) { + foreach ($this->collCouponOrders as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1273,79 +1518,79 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = OrderPeer::ID; + $this->modifiedColumns[] = OrderTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(OrderTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(OrderPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; + if ($this->isColumnModified(OrderTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; } - if ($this->isColumnModified(OrderPeer::CUSTOMER_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_id`'; + if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID'; } - if ($this->isColumnModified(OrderPeer::ADDRESS_INVOICE)) { - $modifiedColumns[':p' . $index++] = '`address_invoice`'; + if ($this->isColumnModified(OrderTableMap::ADDRESS_INVOICE)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS_INVOICE'; } - if ($this->isColumnModified(OrderPeer::ADDRESS_DELIVERY)) { - $modifiedColumns[':p' . $index++] = '`address_delivery`'; + if ($this->isColumnModified(OrderTableMap::ADDRESS_DELIVERY)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS_DELIVERY'; } - if ($this->isColumnModified(OrderPeer::INVOICE_DATE)) { - $modifiedColumns[':p' . $index++] = '`invoice_date`'; + if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_DATE'; } - if ($this->isColumnModified(OrderPeer::CURRENCY_ID)) { - $modifiedColumns[':p' . $index++] = '`currency_id`'; + if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_ID'; } - if ($this->isColumnModified(OrderPeer::CURRENCY_RATE)) { - $modifiedColumns[':p' . $index++] = '`currency_rate`'; + if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE'; } - if ($this->isColumnModified(OrderPeer::TRANSACTION)) { - $modifiedColumns[':p' . $index++] = '`transaction`'; + if ($this->isColumnModified(OrderTableMap::TRANSACTION)) { + $modifiedColumns[':p' . $index++] = 'TRANSACTION'; } - if ($this->isColumnModified(OrderPeer::DELIVERY_NUM)) { - $modifiedColumns[':p' . $index++] = '`delivery_num`'; + if ($this->isColumnModified(OrderTableMap::DELIVERY_NUM)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_NUM'; } - if ($this->isColumnModified(OrderPeer::INVOICE)) { - $modifiedColumns[':p' . $index++] = '`invoice`'; + if ($this->isColumnModified(OrderTableMap::INVOICE)) { + $modifiedColumns[':p' . $index++] = 'INVOICE'; } - if ($this->isColumnModified(OrderPeer::POSTAGE)) { - $modifiedColumns[':p' . $index++] = '`postage`'; + if ($this->isColumnModified(OrderTableMap::POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'POSTAGE'; } - if ($this->isColumnModified(OrderPeer::PAYMENT)) { - $modifiedColumns[':p' . $index++] = '`payment`'; + if ($this->isColumnModified(OrderTableMap::PAYMENT)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT'; } - if ($this->isColumnModified(OrderPeer::CARRIER)) { - $modifiedColumns[':p' . $index++] = '`carrier`'; + if ($this->isColumnModified(OrderTableMap::CARRIER)) { + $modifiedColumns[':p' . $index++] = 'CARRIER'; } - if ($this->isColumnModified(OrderPeer::STATUS_ID)) { - $modifiedColumns[':p' . $index++] = '`status_id`'; + if ($this->isColumnModified(OrderTableMap::STATUS_ID)) { + $modifiedColumns[':p' . $index++] = 'STATUS_ID'; } - if ($this->isColumnModified(OrderPeer::LANG)) { - $modifiedColumns[':p' . $index++] = '`lang`'; + if ($this->isColumnModified(OrderTableMap::LANG)) { + $modifiedColumns[':p' . $index++] = 'LANG'; } - if ($this->isColumnModified(OrderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(OrderTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(OrderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `order` (%s) VALUES (%s)', + 'INSERT INTO order (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1354,72 +1599,72 @@ abstract class BaseOrder extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`ref`': + case 'REF': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`customer_id`': + case 'CUSTOMER_ID': $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); break; - case '`address_invoice`': + case 'ADDRESS_INVOICE': $stmt->bindValue($identifier, $this->address_invoice, PDO::PARAM_INT); break; - case '`address_delivery`': + 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); + case 'INVOICE_DATE': + $stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`currency_id`': + case 'CURRENCY_ID': $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT); break; - case '`currency_rate`': + case 'CURRENCY_RATE': $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR); break; - case '`transaction`': + case 'TRANSACTION': $stmt->bindValue($identifier, $this->transaction, PDO::PARAM_STR); break; - case '`delivery_num`': + case 'DELIVERY_NUM': $stmt->bindValue($identifier, $this->delivery_num, PDO::PARAM_STR); break; - case '`invoice`': + case 'INVOICE': $stmt->bindValue($identifier, $this->invoice, PDO::PARAM_STR); break; - case '`postage`': + case 'POSTAGE': $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); break; - case '`payment`': + case 'PAYMENT': $stmt->bindValue($identifier, $this->payment, PDO::PARAM_STR); break; - case '`carrier`': + case 'CARRIER': $stmt->bindValue($identifier, $this->carrier, PDO::PARAM_STR); break; - case '`status_id`': + case 'STATUS_ID': $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT); break; - case '`lang`': + case 'LANG': $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -1429,156 +1674,32 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = OrderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1588,7 +1709,7 @@ abstract class BaseOrder extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1660,22 +1781,22 @@ abstract class BaseOrder extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = OrderTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getRef(), @@ -1696,6 +1817,12 @@ abstract class BaseOrder extends BaseObject implements Persistent $keys[16] => $this->getCreatedAt(), $keys[17] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aCurrency) { $result['Currency'] = $this->aCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -1726,27 +1853,27 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = OrderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1818,17 +1945,17 @@ abstract class BaseOrder extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = OrderPeer::getFieldNames($keyType); + $keys = OrderTableMap::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]]); @@ -1857,26 +1984,26 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(OrderPeer::DATABASE_NAME); + $criteria = new Criteria(OrderTableMap::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); + if ($this->isColumnModified(OrderTableMap::ID)) $criteria->add(OrderTableMap::ID, $this->id); + if ($this->isColumnModified(OrderTableMap::REF)) $criteria->add(OrderTableMap::REF, $this->ref); + if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) $criteria->add(OrderTableMap::CUSTOMER_ID, $this->customer_id); + if ($this->isColumnModified(OrderTableMap::ADDRESS_INVOICE)) $criteria->add(OrderTableMap::ADDRESS_INVOICE, $this->address_invoice); + if ($this->isColumnModified(OrderTableMap::ADDRESS_DELIVERY)) $criteria->add(OrderTableMap::ADDRESS_DELIVERY, $this->address_delivery); + if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) $criteria->add(OrderTableMap::INVOICE_DATE, $this->invoice_date); + if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) $criteria->add(OrderTableMap::CURRENCY_ID, $this->currency_id); + if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) $criteria->add(OrderTableMap::CURRENCY_RATE, $this->currency_rate); + if ($this->isColumnModified(OrderTableMap::TRANSACTION)) $criteria->add(OrderTableMap::TRANSACTION, $this->transaction); + if ($this->isColumnModified(OrderTableMap::DELIVERY_NUM)) $criteria->add(OrderTableMap::DELIVERY_NUM, $this->delivery_num); + if ($this->isColumnModified(OrderTableMap::INVOICE)) $criteria->add(OrderTableMap::INVOICE, $this->invoice); + if ($this->isColumnModified(OrderTableMap::POSTAGE)) $criteria->add(OrderTableMap::POSTAGE, $this->postage); + if ($this->isColumnModified(OrderTableMap::PAYMENT)) $criteria->add(OrderTableMap::PAYMENT, $this->payment); + if ($this->isColumnModified(OrderTableMap::CARRIER)) $criteria->add(OrderTableMap::CARRIER, $this->carrier); + if ($this->isColumnModified(OrderTableMap::STATUS_ID)) $criteria->add(OrderTableMap::STATUS_ID, $this->status_id); + if ($this->isColumnModified(OrderTableMap::LANG)) $criteria->add(OrderTableMap::LANG, $this->lang); + if ($this->isColumnModified(OrderTableMap::CREATED_AT)) $criteria->add(OrderTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) $criteria->add(OrderTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1891,15 +2018,15 @@ abstract class BaseOrder extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(OrderPeer::DATABASE_NAME); - $criteria->add(OrderPeer::ID, $this->id); + $criteria = new Criteria(OrderTableMap::DATABASE_NAME); + $criteria->add(OrderTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1909,7 +2036,7 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1933,9 +2060,9 @@ abstract class BaseOrder extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1958,12 +2085,10 @@ abstract class BaseOrder extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1977,8 +2102,6 @@ abstract class BaseOrder extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1995,8 +2118,8 @@ abstract class BaseOrder extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Order Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -2010,31 +2133,13 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildCurrency object. * - * 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) + * @param ChildCurrency $v + * @return \Thelia\Model\Order The current object (for fluent API support) * @throws PropelException */ - public function setCurrency(Currency $v = null) + public function setCurrency(ChildCurrency $v = null) { if ($v === null) { $this->setCurrencyId(NULL); @@ -2045,7 +2150,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $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 this object has already been added to the ChildCurrency object, it will not be re-added. if ($v !== null) { $v->addOrder($this); } @@ -2056,17 +2161,16 @@ abstract class BaseOrder extends BaseObject implements Persistent /** - * Get the associated Currency object + * Get the associated ChildCurrency object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Currency The associated Currency object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCurrency The associated ChildCurrency object. * @throws PropelException */ - public function getCurrency(PropelPDO $con = null, $doQuery = true) + public function getCurrency(ConnectionInterface $con = null) { - if ($this->aCurrency === null && ($this->currency_id !== null) && $doQuery) { - $this->aCurrency = CurrencyQuery::create()->findPk($this->currency_id, $con); + if ($this->aCurrency === null && ($this->currency_id !== null)) { + $this->aCurrency = ChildCurrencyQuery::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 @@ -2080,13 +2184,13 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * Declares an association between this object and a Customer object. + * Declares an association between this object and a ChildCustomer object. * - * @param Customer $v - * @return Order The current object (for fluent API support) + * @param ChildCustomer $v + * @return \Thelia\Model\Order The current object (for fluent API support) * @throws PropelException */ - public function setCustomer(Customer $v = null) + public function setCustomer(ChildCustomer $v = null) { if ($v === null) { $this->setCustomerId(NULL); @@ -2097,7 +2201,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $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 this object has already been added to the ChildCustomer object, it will not be re-added. if ($v !== null) { $v->addOrder($this); } @@ -2108,17 +2212,16 @@ abstract class BaseOrder extends BaseObject implements Persistent /** - * Get the associated Customer object + * Get the associated ChildCustomer object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Customer The associated Customer object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCustomer The associated ChildCustomer object. * @throws PropelException */ - public function getCustomer(PropelPDO $con = null, $doQuery = true) + public function getCustomer(ConnectionInterface $con = null) { - if ($this->aCustomer === null && ($this->customer_id !== null) && $doQuery) { - $this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con); + if ($this->aCustomer === null && ($this->customer_id !== null)) { + $this->aCustomer = ChildCustomerQuery::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 @@ -2132,13 +2235,13 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * Declares an association between this object and a OrderAddress object. + * Declares an association between this object and a ChildOrderAddress object. * - * @param OrderAddress $v - * @return Order The current object (for fluent API support) + * @param ChildOrderAddress $v + * @return \Thelia\Model\Order The current object (for fluent API support) * @throws PropelException */ - public function setOrderAddressRelatedByAddressInvoice(OrderAddress $v = null) + public function setOrderAddressRelatedByAddressInvoice(ChildOrderAddress $v = null) { if ($v === null) { $this->setAddressInvoice(NULL); @@ -2149,7 +2252,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $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 this object has already been added to the ChildOrderAddress object, it will not be re-added. if ($v !== null) { $v->addOrderRelatedByAddressInvoice($this); } @@ -2160,17 +2263,16 @@ abstract class BaseOrder extends BaseObject implements Persistent /** - * Get the associated OrderAddress object + * Get the associated ChildOrderAddress object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return OrderAddress The associated OrderAddress object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrderAddress The associated ChildOrderAddress object. * @throws PropelException */ - public function getOrderAddressRelatedByAddressInvoice(PropelPDO $con = null, $doQuery = true) + public function getOrderAddressRelatedByAddressInvoice(ConnectionInterface $con = null) { - if ($this->aOrderAddressRelatedByAddressInvoice === null && ($this->address_invoice !== null) && $doQuery) { - $this->aOrderAddressRelatedByAddressInvoice = OrderAddressQuery::create()->findPk($this->address_invoice, $con); + if ($this->aOrderAddressRelatedByAddressInvoice === null && ($this->address_invoice !== null)) { + $this->aOrderAddressRelatedByAddressInvoice = ChildOrderAddressQuery::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 @@ -2184,13 +2286,13 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * Declares an association between this object and a OrderAddress object. + * Declares an association between this object and a ChildOrderAddress object. * - * @param OrderAddress $v - * @return Order The current object (for fluent API support) + * @param ChildOrderAddress $v + * @return \Thelia\Model\Order The current object (for fluent API support) * @throws PropelException */ - public function setOrderAddressRelatedByAddressDelivery(OrderAddress $v = null) + public function setOrderAddressRelatedByAddressDelivery(ChildOrderAddress $v = null) { if ($v === null) { $this->setAddressDelivery(NULL); @@ -2201,7 +2303,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $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 this object has already been added to the ChildOrderAddress object, it will not be re-added. if ($v !== null) { $v->addOrderRelatedByAddressDelivery($this); } @@ -2212,17 +2314,16 @@ abstract class BaseOrder extends BaseObject implements Persistent /** - * Get the associated OrderAddress object + * Get the associated ChildOrderAddress object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return OrderAddress The associated OrderAddress object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrderAddress The associated ChildOrderAddress object. * @throws PropelException */ - public function getOrderAddressRelatedByAddressDelivery(PropelPDO $con = null, $doQuery = true) + public function getOrderAddressRelatedByAddressDelivery(ConnectionInterface $con = null) { - if ($this->aOrderAddressRelatedByAddressDelivery === null && ($this->address_delivery !== null) && $doQuery) { - $this->aOrderAddressRelatedByAddressDelivery = OrderAddressQuery::create()->findPk($this->address_delivery, $con); + if ($this->aOrderAddressRelatedByAddressDelivery === null && ($this->address_delivery !== null)) { + $this->aOrderAddressRelatedByAddressDelivery = ChildOrderAddressQuery::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 @@ -2236,13 +2337,13 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * Declares an association between this object and a OrderStatus object. + * Declares an association between this object and a ChildOrderStatus object. * - * @param OrderStatus $v - * @return Order The current object (for fluent API support) + * @param ChildOrderStatus $v + * @return \Thelia\Model\Order The current object (for fluent API support) * @throws PropelException */ - public function setOrderStatus(OrderStatus $v = null) + public function setOrderStatus(ChildOrderStatus $v = null) { if ($v === null) { $this->setStatusId(NULL); @@ -2253,7 +2354,7 @@ abstract class BaseOrder extends BaseObject implements Persistent $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 this object has already been added to the ChildOrderStatus object, it will not be re-added. if ($v !== null) { $v->addOrder($this); } @@ -2264,17 +2365,16 @@ abstract class BaseOrder extends BaseObject implements Persistent /** - * Get the associated OrderStatus object + * Get the associated ChildOrderStatus object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return OrderStatus The associated OrderStatus object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrderStatus The associated ChildOrderStatus object. * @throws PropelException */ - public function getOrderStatus(PropelPDO $con = null, $doQuery = true) + public function getOrderStatus(ConnectionInterface $con = null) { - if ($this->aOrderStatus === null && ($this->status_id !== null) && $doQuery) { - $this->aOrderStatus = OrderStatusQuery::create()->findPk($this->status_id, $con); + if ($this->aOrderStatus === null && ($this->status_id !== null)) { + $this->aOrderStatus = ChildOrderStatusQuery::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 @@ -2293,16 +2393,16 @@ abstract class BaseOrder extends BaseObject implements Persistent * 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('OrderProduct' == $relationName) { - $this->initOrderProducts(); + return $this->initOrderProducts(); } if ('CouponOrder' == $relationName) { - $this->initCouponOrders(); + return $this->initCouponOrders(); } } @@ -2312,21 +2412,16 @@ abstract class BaseOrder extends BaseObject implements Persistent * This 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) + * @return void * @see addOrderProducts() */ public function clearOrderProducts() { - $this->collOrderProducts = null; // important to set this to null since that means it is uninitialized - $this->collOrderProductsPartial = null; - - return $this; + $this->collOrderProducts = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collOrderProducts collection loaded partially - * - * @return void + * Reset is the collOrderProducts collection loaded partially. */ public function resetPartialOrderProducts($v = true) { @@ -2340,7 +2435,7 @@ abstract class BaseOrder extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2350,25 +2445,25 @@ abstract class BaseOrder extends BaseObject implements Persistent if (null !== $this->collOrderProducts && !$overrideExisting) { return; } - $this->collOrderProducts = new PropelObjectCollection(); - $this->collOrderProducts->setModel('OrderProduct'); + $this->collOrderProducts = new ObjectCollection(); + $this->collOrderProducts->setModel('\Thelia\Model\OrderProduct'); } /** - * Gets an array of OrderProduct objects which contain a foreign key that references this object. + * Gets an array of ChildOrderProduct objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildOrder is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrderProduct[] List of ChildOrderProduct objects * @throws PropelException */ - public function getOrderProducts($criteria = null, PropelPDO $con = null) + public function getOrderProducts($criteria = null, ConnectionInterface $con = null) { $partial = $this->collOrderProductsPartial && !$this->isNew(); if (null === $this->collOrderProducts || null !== $criteria || $partial) { @@ -2376,29 +2471,31 @@ abstract class BaseOrder extends BaseObject implements Persistent // return empty collection $this->initOrderProducts(); } else { - $collOrderProducts = OrderProductQuery::create(null, $criteria) + $collOrderProducts = ChildOrderProductQuery::create(null, $criteria) ->filterByOrder($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collOrderProductsPartial && count($collOrderProducts)) { - $this->initOrderProducts(false); + $this->initOrderProducts(false); - foreach($collOrderProducts as $obj) { - if (false == $this->collOrderProducts->contains($obj)) { - $this->collOrderProducts->append($obj); + foreach ($collOrderProducts as $obj) { + if (false == $this->collOrderProducts->contains($obj)) { + $this->collOrderProducts->append($obj); + } } - } - $this->collOrderProductsPartial = true; + $this->collOrderProductsPartial = true; } $collOrderProducts->getInternalIterator()->rewind(); + return $collOrderProducts; } - if($partial && $this->collOrderProducts) { - foreach($this->collOrderProducts as $obj) { - if($obj->isNew()) { + if ($partial && $this->collOrderProducts) { + foreach ($this->collOrderProducts as $obj) { + if ($obj->isNew()) { $collOrderProducts[] = $obj; } } @@ -2418,15 +2515,16 @@ abstract class BaseOrder extends BaseObject implements Persistent * It will 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) + * @param Collection $orderProducts A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrder The current object (for fluent API support) */ - public function setOrderProducts(PropelCollection $orderProducts, PropelPDO $con = null) + public function setOrderProducts(Collection $orderProducts, ConnectionInterface $con = null) { $orderProductsToDelete = $this->getOrderProducts(new Criteria(), $con)->diff($orderProducts); - $this->orderProductsScheduledForDeletion = unserialize(serialize($orderProductsToDelete)); + + $this->orderProductsScheduledForDeletion = $orderProductsToDelete; foreach ($orderProductsToDelete as $orderProductRemoved) { $orderProductRemoved->setOrder(null); @@ -2446,13 +2544,13 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Returns the number of related OrderProduct objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related OrderProduct objects. * @throws PropelException */ - public function countOrderProducts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countOrderProducts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collOrderProductsPartial && !$this->isNew(); if (null === $this->collOrderProducts || null !== $criteria || $partial) { @@ -2460,10 +2558,11 @@ abstract class BaseOrder extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getOrderProducts()); } - $query = OrderProductQuery::create(null, $criteria); + + $query = ChildOrderProductQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2477,18 +2576,19 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * Method called to associate a OrderProduct object to this object - * through the OrderProduct foreign key attribute. + * Method called to associate a ChildOrderProduct object to this object + * through the ChildOrderProduct foreign key attribute. * - * @param OrderProduct $l OrderProduct - * @return Order The current object (for fluent API support) + * @param ChildOrderProduct $l ChildOrderProduct + * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function addOrderProduct(OrderProduct $l) + public function addOrderProduct(ChildOrderProduct $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); } @@ -2497,7 +2597,7 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * @param OrderProduct $orderProduct The orderProduct object to add. + * @param OrderProduct $orderProduct The orderProduct object to add. */ protected function doAddOrderProduct($orderProduct) { @@ -2506,8 +2606,8 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * @param OrderProduct $orderProduct The orderProduct object to remove. - * @return Order The current object (for fluent API support) + * @param OrderProduct $orderProduct The orderProduct object to remove. + * @return ChildOrder The current object (for fluent API support) */ public function removeOrderProduct($orderProduct) { @@ -2530,21 +2630,16 @@ abstract class BaseOrder extends BaseObject implements Persistent * This 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) + * @return void * @see addCouponOrders() */ public function clearCouponOrders() { - $this->collCouponOrders = null; // important to set this to null since that means it is uninitialized - $this->collCouponOrdersPartial = null; - - return $this; + $this->collCouponOrders = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collCouponOrders collection loaded partially - * - * @return void + * Reset is the collCouponOrders collection loaded partially. */ public function resetPartialCouponOrders($v = true) { @@ -2558,7 +2653,7 @@ abstract class BaseOrder extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2568,25 +2663,25 @@ abstract class BaseOrder extends BaseObject implements Persistent if (null !== $this->collCouponOrders && !$overrideExisting) { return; } - $this->collCouponOrders = new PropelObjectCollection(); - $this->collCouponOrders->setModel('CouponOrder'); + $this->collCouponOrders = new ObjectCollection(); + $this->collCouponOrders->setModel('\Thelia\Model\CouponOrder'); } /** - * Gets an array of CouponOrder objects which contain a foreign key that references this object. + * Gets an array of ChildCouponOrder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildOrder is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildCouponOrder[] List of ChildCouponOrder objects * @throws PropelException */ - public function getCouponOrders($criteria = null, PropelPDO $con = null) + public function getCouponOrders($criteria = null, ConnectionInterface $con = null) { $partial = $this->collCouponOrdersPartial && !$this->isNew(); if (null === $this->collCouponOrders || null !== $criteria || $partial) { @@ -2594,29 +2689,31 @@ abstract class BaseOrder extends BaseObject implements Persistent // return empty collection $this->initCouponOrders(); } else { - $collCouponOrders = CouponOrderQuery::create(null, $criteria) + $collCouponOrders = ChildCouponOrderQuery::create(null, $criteria) ->filterByOrder($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collCouponOrdersPartial && count($collCouponOrders)) { - $this->initCouponOrders(false); + $this->initCouponOrders(false); - foreach($collCouponOrders as $obj) { - if (false == $this->collCouponOrders->contains($obj)) { - $this->collCouponOrders->append($obj); + foreach ($collCouponOrders as $obj) { + if (false == $this->collCouponOrders->contains($obj)) { + $this->collCouponOrders->append($obj); + } } - } - $this->collCouponOrdersPartial = true; + $this->collCouponOrdersPartial = true; } $collCouponOrders->getInternalIterator()->rewind(); + return $collCouponOrders; } - if($partial && $this->collCouponOrders) { - foreach($this->collCouponOrders as $obj) { - if($obj->isNew()) { + if ($partial && $this->collCouponOrders) { + foreach ($this->collCouponOrders as $obj) { + if ($obj->isNew()) { $collCouponOrders[] = $obj; } } @@ -2636,15 +2733,16 @@ abstract class BaseOrder extends BaseObject implements Persistent * It will 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) + * @param Collection $couponOrders A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrder The current object (for fluent API support) */ - public function setCouponOrders(PropelCollection $couponOrders, PropelPDO $con = null) + public function setCouponOrders(Collection $couponOrders, ConnectionInterface $con = null) { $couponOrdersToDelete = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders); - $this->couponOrdersScheduledForDeletion = unserialize(serialize($couponOrdersToDelete)); + + $this->couponOrdersScheduledForDeletion = $couponOrdersToDelete; foreach ($couponOrdersToDelete as $couponOrderRemoved) { $couponOrderRemoved->setOrder(null); @@ -2664,13 +2762,13 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * Returns the number of related CouponOrder objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related CouponOrder objects. * @throws PropelException */ - public function countCouponOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countCouponOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collCouponOrdersPartial && !$this->isNew(); if (null === $this->collCouponOrders || null !== $criteria || $partial) { @@ -2678,10 +2776,11 @@ abstract class BaseOrder extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getCouponOrders()); } - $query = CouponOrderQuery::create(null, $criteria); + + $query = ChildCouponOrderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2695,18 +2794,19 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * Method called to associate a CouponOrder object to this object - * through the CouponOrder foreign key attribute. + * Method called to associate a ChildCouponOrder object to this object + * through the ChildCouponOrder foreign key attribute. * - * @param CouponOrder $l CouponOrder - * @return Order The current object (for fluent API support) + * @param ChildCouponOrder $l ChildCouponOrder + * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function addCouponOrder(CouponOrder $l) + public function addCouponOrder(ChildCouponOrder $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); } @@ -2715,7 +2815,7 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * @param CouponOrder $couponOrder The couponOrder object to add. + * @param CouponOrder $couponOrder The couponOrder object to add. */ protected function doAddCouponOrder($couponOrder) { @@ -2724,8 +2824,8 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * @param CouponOrder $couponOrder The couponOrder object to remove. - * @return Order The current object (for fluent API support) + * @param CouponOrder $couponOrder The couponOrder object to remove. + * @return ChildOrder The current object (for fluent API support) */ public function removeCouponOrder($couponOrder) { @@ -2766,8 +2866,6 @@ abstract class BaseOrder extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2779,14 +2877,13 @@ abstract class BaseOrder extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collOrderProducts) { foreach ($this->collOrderProducts as $o) { $o->clearAllReferences($deep); @@ -2797,30 +2894,13 @@ abstract class BaseOrder extends BaseObject implements Persistent $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) { + if ($this->collOrderProducts instanceof Collection) { $this->collOrderProducts->clearIterator(); } $this->collOrderProducts = null; - if ($this->collCouponOrders instanceof PropelCollection) { + if ($this->collCouponOrders instanceof Collection) { $this->collCouponOrders->clearIterator(); } $this->collCouponOrders = null; @@ -2832,23 +2912,13 @@ abstract class BaseOrder extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(OrderTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2856,13 +2926,131 @@ abstract class BaseOrder extends BaseObject implements Persistent /** * 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) + * @return ChildOrder The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = OrderPeer::UPDATED_AT; + $this->modifiedColumns[] = OrderTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseOrderAddress.php b/core/lib/Thelia/Model/Base/OrderAddress.php old mode 100755 new mode 100644 similarity index 56% rename from core/lib/Thelia/Model/om/BaseOrderAddress.php rename to core/lib/Thelia/Model/Base/OrderAddress.php index ac3339370..b5ff32951 --- a/core/lib/Thelia/Model/om/BaseOrderAddress.php +++ b/core/lib/Thelia/Model/Base/OrderAddress.php @@ -1,53 +1,61 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderAddress instance. If + * obj is an instance of OrderAddress, delegates to + * equals(OrderAddress). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderAddress The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderAddress The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [customer_title_id] column value. * - * @return int + * @return int */ public function getCustomerTitleId() { + return $this->customer_title_id; } /** * Get the [company] column value. * - * @return string + * @return string */ public function getCompany() { + return $this->company; } /** * Get the [firstname] column value. * - * @return string + * @return string */ public function getFirstname() { + return $this->firstname; } /** * Get the [lastname] column value. * - * @return string + * @return string */ public function getLastname() { + return $this->lastname; } /** * Get the [address1] column value. * - * @return string + * @return string */ public function getAddress1() { + return $this->address1; } /** * Get the [address2] column value. * - * @return string + * @return string */ public function getAddress2() { + return $this->address2; } /** * Get the [address3] column value. * - * @return string + * @return string */ public function getAddress3() { + return $this->address3; } /** * Get the [zipcode] column value. * - * @return string + * @return string */ public function getZipcode() { + return $this->zipcode; } /** * Get the [city] column value. * - * @return string + * @return string */ public function getCity() { + return $this->city; } /** * Get the [phone] column value. * - * @return string + * @return string */ public function getPhone() { + return $this->phone; } /** * Get the [country_id] column value. * - * @return int + * @return int */ public function getCountryId() { + return $this->country_id; } @@ -301,97 +563,57 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = OrderAddressPeer::ID; + $this->modifiedColumns[] = OrderAddressTableMap::ID; } @@ -401,18 +623,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [customer_title_id] column. * - * @param int $v new value - * @return OrderAddress The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setCustomerTitleId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->customer_title_id !== $v) { $this->customer_title_id = $v; - $this->modifiedColumns[] = OrderAddressPeer::CUSTOMER_TITLE_ID; + $this->modifiedColumns[] = OrderAddressTableMap::CUSTOMER_TITLE_ID; } @@ -422,18 +644,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [company] column. * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setCompany($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->company !== $v) { $this->company = $v; - $this->modifiedColumns[] = OrderAddressPeer::COMPANY; + $this->modifiedColumns[] = OrderAddressTableMap::COMPANY; } @@ -443,18 +665,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [firstname] column. * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setFirstname($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->firstname !== $v) { $this->firstname = $v; - $this->modifiedColumns[] = OrderAddressPeer::FIRSTNAME; + $this->modifiedColumns[] = OrderAddressTableMap::FIRSTNAME; } @@ -464,18 +686,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [lastname] column. * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setLastname($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->lastname !== $v) { $this->lastname = $v; - $this->modifiedColumns[] = OrderAddressPeer::LASTNAME; + $this->modifiedColumns[] = OrderAddressTableMap::LASTNAME; } @@ -485,18 +707,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [address1] column. * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setAddress1($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->address1 !== $v) { $this->address1 = $v; - $this->modifiedColumns[] = OrderAddressPeer::ADDRESS1; + $this->modifiedColumns[] = OrderAddressTableMap::ADDRESS1; } @@ -506,18 +728,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [address2] column. * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setAddress2($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->address2 !== $v) { $this->address2 = $v; - $this->modifiedColumns[] = OrderAddressPeer::ADDRESS2; + $this->modifiedColumns[] = OrderAddressTableMap::ADDRESS2; } @@ -527,18 +749,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [address3] column. * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setAddress3($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->address3 !== $v) { $this->address3 = $v; - $this->modifiedColumns[] = OrderAddressPeer::ADDRESS3; + $this->modifiedColumns[] = OrderAddressTableMap::ADDRESS3; } @@ -548,18 +770,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [zipcode] column. * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setZipcode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->zipcode !== $v) { $this->zipcode = $v; - $this->modifiedColumns[] = OrderAddressPeer::ZIPCODE; + $this->modifiedColumns[] = OrderAddressTableMap::ZIPCODE; } @@ -569,18 +791,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [city] column. * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setCity($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->city !== $v) { $this->city = $v; - $this->modifiedColumns[] = OrderAddressPeer::CITY; + $this->modifiedColumns[] = OrderAddressTableMap::CITY; } @@ -590,18 +812,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [phone] column. * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setPhone($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->phone !== $v) { $this->phone = $v; - $this->modifiedColumns[] = OrderAddressPeer::PHONE; + $this->modifiedColumns[] = OrderAddressTableMap::PHONE; } @@ -611,18 +833,18 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Set the value of [country_id] column. * - * @param int $v new value - * @return OrderAddress The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setCountryId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->country_id !== $v) { $this->country_id = $v; - $this->modifiedColumns[] = OrderAddressPeer::COUNTRY_ID; + $this->modifiedColumns[] = OrderAddressTableMap::COUNTRY_ID; } @@ -632,19 +854,17 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderAddressTableMap::CREATED_AT; } } // if either are not null @@ -655,19 +875,17 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderAddressTableMap::UPDATED_AT; } } // if either are not null @@ -685,7 +903,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -697,30 +915,68 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderAddressTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderAddressTableMap::translateFieldName('CustomerTitleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->customer_title_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderAddressTableMap::translateFieldName('Company', TableMap::TYPE_PHPNAME, $indexType)]; + $this->company = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderAddressTableMap::translateFieldName('Firstname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->firstname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderAddressTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)]; + $this->lastname = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderAddressTableMap::translateFieldName('Address1', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address1 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderAddressTableMap::translateFieldName('Address2', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address2 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderAddressTableMap::translateFieldName('Address3', TableMap::TYPE_PHPNAME, $indexType)]; + $this->address3 = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderAddressTableMap::translateFieldName('Zipcode', TableMap::TYPE_PHPNAME, $indexType)]; + $this->zipcode = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderAddressTableMap::translateFieldName('City', TableMap::TYPE_PHPNAME, $indexType)]; + $this->city = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderAddressTableMap::translateFieldName('Phone', TableMap::TYPE_PHPNAME, $indexType)]; + $this->phone = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderAddressTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->country_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderAddressTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderAddressTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -728,11 +984,11 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 14; // 14 = OrderAddressPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 14; // 14 = OrderAddressTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating OrderAddress object", $e); + throw new PropelException("Error populating \Thelia\Model\OrderAddress object", 0, $e); } } @@ -751,7 +1007,6 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -759,12 +1014,12 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -775,19 +1030,19 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(OrderAddressTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildOrderAddressQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -801,26 +1056,25 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see OrderAddress::setDeleted() + * @see OrderAddress::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = OrderAddressQuery::create() + $deleteQuery = ChildOrderAddressQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -845,20 +1099,19 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -868,16 +1121,16 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(OrderAddressPeer::CREATED_AT)) { + if (!$this->isColumnModified(OrderAddressTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(OrderAddressPeer::UPDATED_AT)) { + if (!$this->isColumnModified(OrderAddressTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderAddressPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(OrderAddressTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -889,7 +1142,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - OrderAddressPeer::addInstanceToPool($this); + OrderAddressTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -908,12 +1161,12 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -940,8 +1193,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } } - if ($this->collOrdersRelatedByAddressInvoice !== null) { - foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) { + if ($this->collOrdersRelatedByAddressInvoice !== null) { + foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -958,8 +1211,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } } - if ($this->collOrdersRelatedByAddressDelivery !== null) { - foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) { + if ($this->collOrdersRelatedByAddressDelivery !== null) { + foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -976,67 +1229,67 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = OrderAddressPeer::ID; + $this->modifiedColumns[] = OrderAddressTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderAddressPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderAddressTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderAddressPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(OrderAddressTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(OrderAddressPeer::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_title_id`'; + if ($this->isColumnModified(OrderAddressTableMap::CUSTOMER_TITLE_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_TITLE_ID'; } - if ($this->isColumnModified(OrderAddressPeer::COMPANY)) { - $modifiedColumns[':p' . $index++] = '`company`'; + if ($this->isColumnModified(OrderAddressTableMap::COMPANY)) { + $modifiedColumns[':p' . $index++] = 'COMPANY'; } - if ($this->isColumnModified(OrderAddressPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`firstname`'; + if ($this->isColumnModified(OrderAddressTableMap::FIRSTNAME)) { + $modifiedColumns[':p' . $index++] = 'FIRSTNAME'; } - if ($this->isColumnModified(OrderAddressPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`lastname`'; + if ($this->isColumnModified(OrderAddressTableMap::LASTNAME)) { + $modifiedColumns[':p' . $index++] = 'LASTNAME'; } - if ($this->isColumnModified(OrderAddressPeer::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = '`address1`'; + if ($this->isColumnModified(OrderAddressTableMap::ADDRESS1)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS1'; } - if ($this->isColumnModified(OrderAddressPeer::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = '`address2`'; + if ($this->isColumnModified(OrderAddressTableMap::ADDRESS2)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS2'; } - if ($this->isColumnModified(OrderAddressPeer::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = '`address3`'; + if ($this->isColumnModified(OrderAddressTableMap::ADDRESS3)) { + $modifiedColumns[':p' . $index++] = 'ADDRESS3'; } - if ($this->isColumnModified(OrderAddressPeer::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = '`zipcode`'; + if ($this->isColumnModified(OrderAddressTableMap::ZIPCODE)) { + $modifiedColumns[':p' . $index++] = 'ZIPCODE'; } - if ($this->isColumnModified(OrderAddressPeer::CITY)) { - $modifiedColumns[':p' . $index++] = '`city`'; + if ($this->isColumnModified(OrderAddressTableMap::CITY)) { + $modifiedColumns[':p' . $index++] = 'CITY'; } - if ($this->isColumnModified(OrderAddressPeer::PHONE)) { - $modifiedColumns[':p' . $index++] = '`phone`'; + if ($this->isColumnModified(OrderAddressTableMap::PHONE)) { + $modifiedColumns[':p' . $index++] = 'PHONE'; } - if ($this->isColumnModified(OrderAddressPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`country_id`'; + if ($this->isColumnModified(OrderAddressTableMap::COUNTRY_ID)) { + $modifiedColumns[':p' . $index++] = 'COUNTRY_ID'; } - if ($this->isColumnModified(OrderAddressPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(OrderAddressTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(OrderAddressPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(OrderAddressTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `order_address` (%s) VALUES (%s)', + 'INSERT INTO order_address (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1045,60 +1298,60 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`customer_title_id`': + case 'CUSTOMER_TITLE_ID': $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); break; - case '`company`': + case 'COMPANY': $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); break; - case '`firstname`': + case 'FIRSTNAME': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; - case '`lastname`': + case 'LASTNAME': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; - case '`address1`': + case 'ADDRESS1': $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); break; - case '`address2`': + case 'ADDRESS2': $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); break; - case '`address3`': + case 'ADDRESS3': $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); break; - case '`zipcode`': + case 'ZIPCODE': $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); break; - case '`city`': + case 'CITY': $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); break; - case '`phone`': + case 'PHONE': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; - case '`country_id`': + 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); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -1108,120 +1361,32 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderAddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = OrderAddressTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1231,7 +1396,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1291,22 +1456,22 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = OrderAddressTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCustomerTitleId(), @@ -1323,6 +1488,12 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $keys[12] => $this->getCreatedAt(), $keys[13] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collOrdersRelatedByAddressInvoice) { $result['OrdersRelatedByAddressInvoice'] = $this->collOrdersRelatedByAddressInvoice->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1338,27 +1509,27 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderAddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = OrderAddressTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1418,17 +1589,17 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = OrderAddressPeer::getFieldNames($keyType); + $keys = OrderAddressTableMap::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]]); @@ -1453,22 +1624,22 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME); + $criteria = new Criteria(OrderAddressTableMap::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); + if ($this->isColumnModified(OrderAddressTableMap::ID)) $criteria->add(OrderAddressTableMap::ID, $this->id); + if ($this->isColumnModified(OrderAddressTableMap::CUSTOMER_TITLE_ID)) $criteria->add(OrderAddressTableMap::CUSTOMER_TITLE_ID, $this->customer_title_id); + if ($this->isColumnModified(OrderAddressTableMap::COMPANY)) $criteria->add(OrderAddressTableMap::COMPANY, $this->company); + if ($this->isColumnModified(OrderAddressTableMap::FIRSTNAME)) $criteria->add(OrderAddressTableMap::FIRSTNAME, $this->firstname); + if ($this->isColumnModified(OrderAddressTableMap::LASTNAME)) $criteria->add(OrderAddressTableMap::LASTNAME, $this->lastname); + if ($this->isColumnModified(OrderAddressTableMap::ADDRESS1)) $criteria->add(OrderAddressTableMap::ADDRESS1, $this->address1); + if ($this->isColumnModified(OrderAddressTableMap::ADDRESS2)) $criteria->add(OrderAddressTableMap::ADDRESS2, $this->address2); + if ($this->isColumnModified(OrderAddressTableMap::ADDRESS3)) $criteria->add(OrderAddressTableMap::ADDRESS3, $this->address3); + if ($this->isColumnModified(OrderAddressTableMap::ZIPCODE)) $criteria->add(OrderAddressTableMap::ZIPCODE, $this->zipcode); + if ($this->isColumnModified(OrderAddressTableMap::CITY)) $criteria->add(OrderAddressTableMap::CITY, $this->city); + if ($this->isColumnModified(OrderAddressTableMap::PHONE)) $criteria->add(OrderAddressTableMap::PHONE, $this->phone); + if ($this->isColumnModified(OrderAddressTableMap::COUNTRY_ID)) $criteria->add(OrderAddressTableMap::COUNTRY_ID, $this->country_id); + if ($this->isColumnModified(OrderAddressTableMap::CREATED_AT)) $criteria->add(OrderAddressTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderAddressTableMap::UPDATED_AT)) $criteria->add(OrderAddressTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1483,15 +1654,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME); - $criteria->add(OrderAddressPeer::ID, $this->id); + $criteria = new Criteria(OrderAddressTableMap::DATABASE_NAME); + $criteria->add(OrderAddressTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1501,7 +1672,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1525,9 +1696,9 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1546,12 +1717,10 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1565,8 +1734,6 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1583,8 +1750,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\OrderAddress Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1597,40 +1764,22 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('OrderRelatedByAddressInvoice' == $relationName) { - $this->initOrdersRelatedByAddressInvoice(); + return $this->initOrdersRelatedByAddressInvoice(); } if ('OrderRelatedByAddressDelivery' == $relationName) { - $this->initOrdersRelatedByAddressDelivery(); + return $this->initOrdersRelatedByAddressDelivery(); } } @@ -1640,21 +1789,16 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * This 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) + * @return void * @see addOrdersRelatedByAddressInvoice() */ public function clearOrdersRelatedByAddressInvoice() { - $this->collOrdersRelatedByAddressInvoice = null; // important to set this to null since that means it is uninitialized - $this->collOrdersRelatedByAddressInvoicePartial = null; - - return $this; + $this->collOrdersRelatedByAddressInvoice = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collOrdersRelatedByAddressInvoice collection loaded partially - * - * @return void + * Reset is the collOrdersRelatedByAddressInvoice collection loaded partially. */ public function resetPartialOrdersRelatedByAddressInvoice($v = true) { @@ -1668,7 +1812,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1678,25 +1822,25 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent if (null !== $this->collOrdersRelatedByAddressInvoice && !$overrideExisting) { return; } - $this->collOrdersRelatedByAddressInvoice = new PropelObjectCollection(); - $this->collOrdersRelatedByAddressInvoice->setModel('Order'); + $this->collOrdersRelatedByAddressInvoice = new ObjectCollection(); + $this->collOrdersRelatedByAddressInvoice->setModel('\Thelia\Model\Order'); } /** - * Gets an array of Order objects which contain a foreign key that references this object. + * Gets an array of ChildOrder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildOrderAddress is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects * @throws PropelException */ - public function getOrdersRelatedByAddressInvoice($criteria = null, PropelPDO $con = null) + public function getOrdersRelatedByAddressInvoice($criteria = null, ConnectionInterface $con = null) { $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew(); if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) { @@ -1704,29 +1848,31 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent // return empty collection $this->initOrdersRelatedByAddressInvoice(); } else { - $collOrdersRelatedByAddressInvoice = OrderQuery::create(null, $criteria) + $collOrdersRelatedByAddressInvoice = ChildOrderQuery::create(null, $criteria) ->filterByOrderAddressRelatedByAddressInvoice($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collOrdersRelatedByAddressInvoicePartial && count($collOrdersRelatedByAddressInvoice)) { - $this->initOrdersRelatedByAddressInvoice(false); + $this->initOrdersRelatedByAddressInvoice(false); - foreach($collOrdersRelatedByAddressInvoice as $obj) { - if (false == $this->collOrdersRelatedByAddressInvoice->contains($obj)) { - $this->collOrdersRelatedByAddressInvoice->append($obj); + foreach ($collOrdersRelatedByAddressInvoice as $obj) { + if (false == $this->collOrdersRelatedByAddressInvoice->contains($obj)) { + $this->collOrdersRelatedByAddressInvoice->append($obj); + } } - } - $this->collOrdersRelatedByAddressInvoicePartial = true; + $this->collOrdersRelatedByAddressInvoicePartial = true; } $collOrdersRelatedByAddressInvoice->getInternalIterator()->rewind(); + return $collOrdersRelatedByAddressInvoice; } - if($partial && $this->collOrdersRelatedByAddressInvoice) { - foreach($this->collOrdersRelatedByAddressInvoice as $obj) { - if($obj->isNew()) { + if ($partial && $this->collOrdersRelatedByAddressInvoice) { + foreach ($this->collOrdersRelatedByAddressInvoice as $obj) { + if ($obj->isNew()) { $collOrdersRelatedByAddressInvoice[] = $obj; } } @@ -1746,15 +1892,16 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * It will 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) + * @param Collection $ordersRelatedByAddressInvoice A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrderAddress The current object (for fluent API support) */ - public function setOrdersRelatedByAddressInvoice(PropelCollection $ordersRelatedByAddressInvoice, PropelPDO $con = null) + public function setOrdersRelatedByAddressInvoice(Collection $ordersRelatedByAddressInvoice, ConnectionInterface $con = null) { $ordersRelatedByAddressInvoiceToDelete = $this->getOrdersRelatedByAddressInvoice(new Criteria(), $con)->diff($ordersRelatedByAddressInvoice); - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = unserialize(serialize($ordersRelatedByAddressInvoiceToDelete)); + + $this->ordersRelatedByAddressInvoiceScheduledForDeletion = $ordersRelatedByAddressInvoiceToDelete; foreach ($ordersRelatedByAddressInvoiceToDelete as $orderRelatedByAddressInvoiceRemoved) { $orderRelatedByAddressInvoiceRemoved->setOrderAddressRelatedByAddressInvoice(null); @@ -1774,13 +1921,13 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Returns the number of related Order objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Order objects. * @throws PropelException */ - public function countOrdersRelatedByAddressInvoice(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countOrdersRelatedByAddressInvoice(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew(); if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) { @@ -1788,10 +1935,11 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getOrdersRelatedByAddressInvoice()); } - $query = OrderQuery::create(null, $criteria); + + $query = ChildOrderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1805,18 +1953,19 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. * - * @param Order $l Order - * @return OrderAddress The current object (for fluent API support) + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ - public function addOrderRelatedByAddressInvoice(Order $l) + public function addOrderRelatedByAddressInvoice(ChildOrder $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); } @@ -1825,7 +1974,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } /** - * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to add. + * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to add. */ protected function doAddOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice) { @@ -1834,8 +1983,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } /** - * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to remove. - * @return OrderAddress The current object (for fluent API support) + * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to remove. + * @return ChildOrderAddress The current object (for fluent API support) */ public function removeOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice) { @@ -1864,15 +2013,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressInvoiceJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByAddressInvoiceJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Currency', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); return $this->getOrdersRelatedByAddressInvoice($query, $con); } @@ -1889,15 +2038,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressInvoiceJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByAddressInvoiceJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); return $this->getOrdersRelatedByAddressInvoice($query, $con); } @@ -1914,15 +2063,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressInvoiceJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByAddressInvoiceJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderStatus', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); return $this->getOrdersRelatedByAddressInvoice($query, $con); } @@ -1933,21 +2082,16 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * This 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) + * @return void * @see addOrdersRelatedByAddressDelivery() */ public function clearOrdersRelatedByAddressDelivery() { - $this->collOrdersRelatedByAddressDelivery = null; // important to set this to null since that means it is uninitialized - $this->collOrdersRelatedByAddressDeliveryPartial = null; - - return $this; + $this->collOrdersRelatedByAddressDelivery = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collOrdersRelatedByAddressDelivery collection loaded partially - * - * @return void + * Reset is the collOrdersRelatedByAddressDelivery collection loaded partially. */ public function resetPartialOrdersRelatedByAddressDelivery($v = true) { @@ -1961,7 +2105,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1971,25 +2115,25 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent if (null !== $this->collOrdersRelatedByAddressDelivery && !$overrideExisting) { return; } - $this->collOrdersRelatedByAddressDelivery = new PropelObjectCollection(); - $this->collOrdersRelatedByAddressDelivery->setModel('Order'); + $this->collOrdersRelatedByAddressDelivery = new ObjectCollection(); + $this->collOrdersRelatedByAddressDelivery->setModel('\Thelia\Model\Order'); } /** - * Gets an array of Order objects which contain a foreign key that references this object. + * Gets an array of ChildOrder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildOrderAddress is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects * @throws PropelException */ - public function getOrdersRelatedByAddressDelivery($criteria = null, PropelPDO $con = null) + public function getOrdersRelatedByAddressDelivery($criteria = null, ConnectionInterface $con = null) { $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew(); if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) { @@ -1997,29 +2141,31 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent // return empty collection $this->initOrdersRelatedByAddressDelivery(); } else { - $collOrdersRelatedByAddressDelivery = OrderQuery::create(null, $criteria) + $collOrdersRelatedByAddressDelivery = ChildOrderQuery::create(null, $criteria) ->filterByOrderAddressRelatedByAddressDelivery($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collOrdersRelatedByAddressDeliveryPartial && count($collOrdersRelatedByAddressDelivery)) { - $this->initOrdersRelatedByAddressDelivery(false); + $this->initOrdersRelatedByAddressDelivery(false); - foreach($collOrdersRelatedByAddressDelivery as $obj) { - if (false == $this->collOrdersRelatedByAddressDelivery->contains($obj)) { - $this->collOrdersRelatedByAddressDelivery->append($obj); + foreach ($collOrdersRelatedByAddressDelivery as $obj) { + if (false == $this->collOrdersRelatedByAddressDelivery->contains($obj)) { + $this->collOrdersRelatedByAddressDelivery->append($obj); + } } - } - $this->collOrdersRelatedByAddressDeliveryPartial = true; + $this->collOrdersRelatedByAddressDeliveryPartial = true; } $collOrdersRelatedByAddressDelivery->getInternalIterator()->rewind(); + return $collOrdersRelatedByAddressDelivery; } - if($partial && $this->collOrdersRelatedByAddressDelivery) { - foreach($this->collOrdersRelatedByAddressDelivery as $obj) { - if($obj->isNew()) { + if ($partial && $this->collOrdersRelatedByAddressDelivery) { + foreach ($this->collOrdersRelatedByAddressDelivery as $obj) { + if ($obj->isNew()) { $collOrdersRelatedByAddressDelivery[] = $obj; } } @@ -2039,15 +2185,16 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * It will 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) + * @param Collection $ordersRelatedByAddressDelivery A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrderAddress The current object (for fluent API support) */ - public function setOrdersRelatedByAddressDelivery(PropelCollection $ordersRelatedByAddressDelivery, PropelPDO $con = null) + public function setOrdersRelatedByAddressDelivery(Collection $ordersRelatedByAddressDelivery, ConnectionInterface $con = null) { $ordersRelatedByAddressDeliveryToDelete = $this->getOrdersRelatedByAddressDelivery(new Criteria(), $con)->diff($ordersRelatedByAddressDelivery); - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = unserialize(serialize($ordersRelatedByAddressDeliveryToDelete)); + + $this->ordersRelatedByAddressDeliveryScheduledForDeletion = $ordersRelatedByAddressDeliveryToDelete; foreach ($ordersRelatedByAddressDeliveryToDelete as $orderRelatedByAddressDeliveryRemoved) { $orderRelatedByAddressDeliveryRemoved->setOrderAddressRelatedByAddressDelivery(null); @@ -2067,13 +2214,13 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * Returns the number of related Order objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Order objects. * @throws PropelException */ - public function countOrdersRelatedByAddressDelivery(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countOrdersRelatedByAddressDelivery(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew(); if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) { @@ -2081,10 +2228,11 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getOrdersRelatedByAddressDelivery()); } - $query = OrderQuery::create(null, $criteria); + + $query = ChildOrderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2098,18 +2246,19 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. * - * @param Order $l Order - * @return OrderAddress The current object (for fluent API support) + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\OrderAddress The current object (for fluent API support) */ - public function addOrderRelatedByAddressDelivery(Order $l) + public function addOrderRelatedByAddressDelivery(ChildOrder $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); } @@ -2118,7 +2267,7 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } /** - * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to add. + * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to add. */ protected function doAddOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery) { @@ -2127,8 +2276,8 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent } /** - * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to remove. - * @return OrderAddress The current object (for fluent API support) + * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to remove. + * @return ChildOrderAddress The current object (for fluent API support) */ public function removeOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery) { @@ -2157,15 +2306,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressDeliveryJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByAddressDeliveryJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Currency', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); return $this->getOrdersRelatedByAddressDelivery($query, $con); } @@ -2182,15 +2331,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressDeliveryJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByAddressDeliveryJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); return $this->getOrdersRelatedByAddressDelivery($query, $con); } @@ -2207,15 +2356,15 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersRelatedByAddressDeliveryJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersRelatedByAddressDeliveryJoinOrderStatus($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderStatus', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderStatus', $joinBehavior); return $this->getOrdersRelatedByAddressDelivery($query, $con); } @@ -2240,8 +2389,6 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2253,14 +2400,13 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collOrdersRelatedByAddressInvoice) { foreach ($this->collOrdersRelatedByAddressInvoice as $o) { $o->clearAllReferences($deep); @@ -2271,38 +2417,26 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) - if ($this->collOrdersRelatedByAddressInvoice instanceof PropelCollection) { + if ($this->collOrdersRelatedByAddressInvoice instanceof Collection) { $this->collOrdersRelatedByAddressInvoice->clearIterator(); } $this->collOrdersRelatedByAddressInvoice = null; - if ($this->collOrdersRelatedByAddressDelivery instanceof PropelCollection) { + if ($this->collOrdersRelatedByAddressDelivery instanceof Collection) { $this->collOrdersRelatedByAddressDelivery->clearIterator(); } $this->collOrdersRelatedByAddressDelivery = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(OrderAddressTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2310,13 +2444,131 @@ abstract class BaseOrderAddress extends BaseObject implements Persistent /** * 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) + * @return ChildOrderAddress The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = OrderAddressPeer::UPDATED_AT; + $this->modifiedColumns[] = OrderAddressTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php b/core/lib/Thelia/Model/Base/OrderAddressQuery.php old mode 100755 new mode 100644 similarity index 54% rename from core/lib/Thelia/Model/om/BaseOrderAddressQuery.php rename to core/lib/Thelia/Model/Base/OrderAddressQuery.php index 71b8135e5..0552feb85 --- a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php +++ b/core/lib/Thelia/Model/Base/OrderAddressQuery.php @@ -1,131 +1,131 @@ setModelAlias($modelAlias); } @@ -146,21 +146,21 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return OrderAddress|OrderAddress[]|mixed the result, formatted by the current formatter + * @return ChildOrderAddress|array|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 + if ((null !== ($obj = OrderAddressTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(OrderAddressTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -172,46 +172,31 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return OrderAddress A model object, or null if the key is not found - * @throws PropelException + * @return ChildOrderAddress A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new OrderAddress(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderAddress(); $obj->hydrate($row); - OrderAddressPeer::addInstanceToPool($obj, (string) $key); + OrderAddressTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -222,19 +207,19 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return OrderAddress|OrderAddress[]|mixed the result, formatted by the current formatter + * @return ChildOrderAddress|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -243,22 +228,22 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|OrderAddress[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -266,12 +251,12 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return OrderAddressQuery The current query, for fluid interface + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(OrderAddressPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(OrderAddressTableMap::ID, $key, Criteria::EQUAL); } /** @@ -279,12 +264,12 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return OrderAddressQuery The current query, for fluid interface + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(OrderAddressPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(OrderAddressTableMap::ID, $keys, Criteria::IN); } /** @@ -294,8 +279,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -304,18 +288,18 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery 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); + $this->addUsingAlias(OrderAddressTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(OrderAddressPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderAddressTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -326,7 +310,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::ID, $id, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::ID, $id, $comparison); } /** @@ -336,8 +320,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * $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 + * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id > 12 * * * @param mixed $customerTitleId The value to use as filter. @@ -346,18 +329,18 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery 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); + $this->addUsingAlias(OrderAddressTableMap::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); + $this->addUsingAlias(OrderAddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -368,7 +351,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); } /** @@ -384,7 +367,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByCompany($company = null, $comparison = null) { @@ -397,7 +380,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::COMPANY, $company, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::COMPANY, $company, $comparison); } /** @@ -413,7 +396,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByFirstname($firstname = null, $comparison = null) { @@ -426,7 +409,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::FIRSTNAME, $firstname, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::FIRSTNAME, $firstname, $comparison); } /** @@ -442,7 +425,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByLastname($lastname = null, $comparison = null) { @@ -455,7 +438,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::LASTNAME, $lastname, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::LASTNAME, $lastname, $comparison); } /** @@ -471,7 +454,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByAddress1($address1 = null, $comparison = null) { @@ -484,7 +467,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::ADDRESS1, $address1, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::ADDRESS1, $address1, $comparison); } /** @@ -500,7 +483,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByAddress2($address2 = null, $comparison = null) { @@ -513,7 +496,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::ADDRESS2, $address2, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::ADDRESS2, $address2, $comparison); } /** @@ -529,7 +512,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByAddress3($address3 = null, $comparison = null) { @@ -542,7 +525,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::ADDRESS3, $address3, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::ADDRESS3, $address3, $comparison); } /** @@ -558,7 +541,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByZipcode($zipcode = null, $comparison = null) { @@ -571,7 +554,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::ZIPCODE, $zipcode, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::ZIPCODE, $zipcode, $comparison); } /** @@ -587,7 +570,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByCity($city = null, $comparison = null) { @@ -600,7 +583,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::CITY, $city, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::CITY, $city, $comparison); } /** @@ -616,7 +599,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByPhone($phone = null, $comparison = null) { @@ -629,7 +612,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::PHONE, $phone, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::PHONE, $phone, $comparison); } /** @@ -639,8 +622,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * $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 + * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 * * * @param mixed $countryId The value to use as filter. @@ -649,18 +631,18 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery 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); + $this->addUsingAlias(OrderAddressTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($countryId['max'])) { - $this->addUsingAlias(OrderAddressPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderAddressTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -671,7 +653,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::COUNTRY_ID, $countryId, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::COUNTRY_ID, $countryId, $comparison); } /** @@ -692,18 +674,18 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery 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); + $this->addUsingAlias(OrderAddressTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderAddressPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderAddressTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -714,7 +696,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -735,18 +717,18 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * 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 + * @return ChildOrderAddressQuery 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); + $this->addUsingAlias(OrderAddressTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderAddressTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -757,30 +739,29 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(OrderAddressTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Order object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Order|ObjectCollection $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. + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByOrderRelatedByAddressInvoice($order, $comparison = null) { - if ($order instanceof Order) { + if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(OrderAddressPeer::ID, $order->getAddressInvoice(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { + ->addUsingAlias(OrderAddressTableMap::ID, $order->getAddressInvoice(), $comparison); + } elseif ($order instanceof ObjectCollection) { return $this ->useOrderRelatedByAddressInvoiceQuery() ->filterByPrimaryKeys($order->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderRelatedByAddressInvoice() only accepts arguments of type Order or PropelCollection'); + throw new PropelException('filterByOrderRelatedByAddressInvoice() only accepts arguments of type \Thelia\Model\Order or Collection'); } } @@ -790,7 +771,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * @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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function joinOrderRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -819,7 +800,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria /** * Use the OrderRelatedByAddressInvoice relation Order object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -835,26 +816,25 @@ abstract class BaseOrderAddressQuery extends ModelCriteria } /** - * Filter the query by a related Order object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Order|ObjectCollection $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. + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function filterByOrderRelatedByAddressDelivery($order, $comparison = null) { - if ($order instanceof Order) { + if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(OrderAddressPeer::ID, $order->getAddressDelivery(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { + ->addUsingAlias(OrderAddressTableMap::ID, $order->getAddressDelivery(), $comparison); + } elseif ($order instanceof ObjectCollection) { return $this ->useOrderRelatedByAddressDeliveryQuery() ->filterByPrimaryKeys($order->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderRelatedByAddressDelivery() only accepts arguments of type Order or PropelCollection'); + throw new PropelException('filterByOrderRelatedByAddressDelivery() only accepts arguments of type \Thelia\Model\Order or Collection'); } } @@ -864,7 +844,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * @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 + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function joinOrderRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -893,7 +873,7 @@ abstract class BaseOrderAddressQuery extends ModelCriteria /** * Use the OrderRelatedByAddressDelivery relation Order object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -911,19 +891,94 @@ abstract class BaseOrderAddressQuery extends ModelCriteria /** * Exclude object from result * - * @param OrderAddress $orderAddress Object to remove from the list of results + * @param ChildOrderAddress $orderAddress Object to remove from the list of results * - * @return OrderAddressQuery The current query, for fluid interface + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function prune($orderAddress = null) { if ($orderAddress) { - $this->addUsingAlias(OrderAddressPeer::ID, $orderAddress->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(OrderAddressTableMap::ID, $orderAddress->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the order_address table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderAddressTableMap::clearInstancePool(); + OrderAddressTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderAddress or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderAddress object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderAddressTableMap::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(); + + + OrderAddressTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderAddressTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -931,31 +986,11 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return OrderAddressQuery The current query, for fluid interface + * @return ChildOrderAddressQuery 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); + return $this->addUsingAlias(OrderAddressTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -963,30 +998,51 @@ abstract class BaseOrderAddressQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return OrderAddressQuery The current query, for fluid interface + * @return ChildOrderAddressQuery 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); + return $this->addUsingAlias(OrderAddressTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderAddressQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderAddressTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderAddressQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderAddressTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return OrderAddressQuery The current query, for fluid interface + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(OrderAddressPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(OrderAddressTableMap::CREATED_AT); } /** * Order by create date asc * - * @return OrderAddressQuery The current query, for fluid interface + * @return ChildOrderAddressQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(OrderAddressPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(OrderAddressTableMap::CREATED_AT); } -} + +} // OrderAddressQuery diff --git a/core/lib/Thelia/Model/Base/OrderFeature.php b/core/lib/Thelia/Model/Base/OrderFeature.php new file mode 100644 index 000000000..49c1a0911 --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderFeature.php @@ -0,0 +1,1476 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderFeature instance. If + * obj is an instance of OrderFeature, delegates to + * equals(OrderFeature). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderFeature The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderFeature The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderFeature The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = OrderFeatureTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [order_product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\OrderFeature The current object (for fluent API support) + */ + public function setOrderProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->order_product_id !== $v) { + $this->order_product_id = $v; + $this->modifiedColumns[] = OrderFeatureTableMap::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 \Thelia\Model\OrderFeature The current object (for fluent API support) + */ + public function setFeatureDesc($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->feature_desc !== $v) { + $this->feature_desc = $v; + $this->modifiedColumns[] = OrderFeatureTableMap::FEATURE_DESC; + } + + + return $this; + } // setFeatureDesc() + + /** + * Set the value of [feature_av_desc] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderFeature The current object (for fluent API support) + */ + public function setFeatureAvDesc($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->feature_av_desc !== $v) { + $this->feature_av_desc = $v; + $this->modifiedColumns[] = OrderFeatureTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderFeatureTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderFeatureTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderFeatureTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderFeatureTableMap::translateFieldName('OrderProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderFeatureTableMap::translateFieldName('FeatureDesc', TableMap::TYPE_PHPNAME, $indexType)]; + $this->feature_desc = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderFeatureTableMap::translateFieldName('FeatureAvDesc', TableMap::TYPE_PHPNAME, $indexType)]; + $this->feature_av_desc = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderFeatureTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderFeatureTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = OrderFeatureTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\OrderFeature object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(OrderFeatureTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildOrderFeatureQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aOrderProduct = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see OrderFeature::setDeleted() + * @see OrderFeature::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildOrderFeatureQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(OrderFeatureTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(OrderFeatureTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(OrderFeatureTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + OrderFeatureTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderFeatureTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderFeatureTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderFeatureTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderFeatureTableMap::ORDER_PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_PRODUCT_ID'; + } + if ($this->isColumnModified(OrderFeatureTableMap::FEATURE_DESC)) { + $modifiedColumns[':p' . $index++] = 'FEATURE_DESC'; + } + if ($this->isColumnModified(OrderFeatureTableMap::FEATURE_AV_DESC)) { + $modifiedColumns[':p' . $index++] = 'FEATURE_AV_DESC'; + } + if ($this->isColumnModified(OrderFeatureTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderFeatureTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderFeatureTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['OrderFeature'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['OrderFeature'][$this->getPrimaryKey()] = true; + $keys = OrderFeatureTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderFeatureTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = OrderFeatureTableMap::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(OrderFeatureTableMap::DATABASE_NAME); + + if ($this->isColumnModified(OrderFeatureTableMap::ID)) $criteria->add(OrderFeatureTableMap::ID, $this->id); + if ($this->isColumnModified(OrderFeatureTableMap::ORDER_PRODUCT_ID)) $criteria->add(OrderFeatureTableMap::ORDER_PRODUCT_ID, $this->order_product_id); + if ($this->isColumnModified(OrderFeatureTableMap::FEATURE_DESC)) $criteria->add(OrderFeatureTableMap::FEATURE_DESC, $this->feature_desc); + if ($this->isColumnModified(OrderFeatureTableMap::FEATURE_AV_DESC)) $criteria->add(OrderFeatureTableMap::FEATURE_AV_DESC, $this->feature_av_desc); + if ($this->isColumnModified(OrderFeatureTableMap::CREATED_AT)) $criteria->add(OrderFeatureTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderFeatureTableMap::UPDATED_AT)) $criteria->add(OrderFeatureTableMap::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(OrderFeatureTableMap::DATABASE_NAME); + $criteria->add(OrderFeatureTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildOrderProduct object. + * + * @param ChildOrderProduct $v + * @return \Thelia\Model\OrderFeature The current object (for fluent API support) + * @throws PropelException + */ + public function setOrderProduct(ChildOrderProduct $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 ChildOrderProduct object, it will not be re-added. + if ($v !== null) { + $v->addOrderFeature($this); + } + + + return $this; + } + + + /** + * Get the associated ChildOrderProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrderProduct The associated ChildOrderProduct object. + * @throws PropelException + */ + public function getOrderProduct(ConnectionInterface $con = null) + { + if ($this->aOrderProduct === null && ($this->order_product_id !== null)) { + $this->aOrderProduct = ChildOrderProductQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aOrderProduct = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(OrderFeatureTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildOrderFeature The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = OrderFeatureTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php b/core/lib/Thelia/Model/Base/OrderFeatureQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php rename to core/lib/Thelia/Model/Base/OrderFeatureQuery.php index 41c1b48c5..5c59b36e8 --- a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php +++ b/core/lib/Thelia/Model/Base/OrderFeatureQuery.php @@ -1,95 +1,95 @@ setModelAlias($modelAlias); } @@ -110,21 +110,21 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return OrderFeature|OrderFeature[]|mixed the result, formatted by the current formatter + * @return ChildOrderFeature|array|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 + if ((null !== ($obj = OrderFeatureTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(OrderFeatureTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -136,46 +136,31 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return OrderFeature A model object, or null if the key is not found - * @throws PropelException + * @return ChildOrderFeature A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new OrderFeature(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderFeature(); $obj->hydrate($row); - OrderFeaturePeer::addInstanceToPool($obj, (string) $key); + OrderFeatureTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -186,19 +171,19 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return OrderFeature|OrderFeature[]|mixed the result, formatted by the current formatter + * @return ChildOrderFeature|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -207,22 +192,22 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|OrderFeature[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -230,12 +215,12 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return OrderFeatureQuery The current query, for fluid interface + * @return ChildOrderFeatureQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(OrderFeaturePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(OrderFeatureTableMap::ID, $key, Criteria::EQUAL); } /** @@ -243,12 +228,12 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return OrderFeatureQuery The current query, for fluid interface + * @return ChildOrderFeatureQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(OrderFeaturePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(OrderFeatureTableMap::ID, $keys, Criteria::IN); } /** @@ -258,8 +243,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -268,18 +252,18 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * 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 + * @return ChildOrderFeatureQuery 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); + $this->addUsingAlias(OrderFeatureTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(OrderFeaturePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderFeatureTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -290,7 +274,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderFeaturePeer::ID, $id, $comparison); + return $this->addUsingAlias(OrderFeatureTableMap::ID, $id, $comparison); } /** @@ -300,8 +284,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * * $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 + * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id > 12 * * * @see filterByOrderProduct() @@ -312,18 +295,18 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * 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 + * @return ChildOrderFeatureQuery 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); + $this->addUsingAlias(OrderFeatureTableMap::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); + $this->addUsingAlias(OrderFeatureTableMap::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -334,7 +317,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProductId, $comparison); + return $this->addUsingAlias(OrderFeatureTableMap::ORDER_PRODUCT_ID, $orderProductId, $comparison); } /** @@ -350,7 +333,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * 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 + * @return ChildOrderFeatureQuery The current query, for fluid interface */ public function filterByFeatureDesc($featureDesc = null, $comparison = null) { @@ -363,7 +346,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderFeaturePeer::FEATURE_DESC, $featureDesc, $comparison); + return $this->addUsingAlias(OrderFeatureTableMap::FEATURE_DESC, $featureDesc, $comparison); } /** @@ -379,7 +362,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * 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 + * @return ChildOrderFeatureQuery The current query, for fluid interface */ public function filterByFeatureAvDesc($featureAvDesc = null, $comparison = null) { @@ -392,7 +375,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderFeaturePeer::FEATURE_AV_DESC, $featureAvDesc, $comparison); + return $this->addUsingAlias(OrderFeatureTableMap::FEATURE_AV_DESC, $featureAvDesc, $comparison); } /** @@ -413,18 +396,18 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * 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 + * @return ChildOrderFeatureQuery 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); + $this->addUsingAlias(OrderFeatureTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderFeatureTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -435,7 +418,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(OrderFeatureTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -456,18 +439,18 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * 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 + * @return ChildOrderFeatureQuery 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); + $this->addUsingAlias(OrderFeatureTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderFeatureTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -478,32 +461,31 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(OrderFeatureTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related OrderProduct object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\OrderProduct|ObjectCollection $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. + * @return ChildOrderFeatureQuery The current query, for fluid interface */ public function filterByOrderProduct($orderProduct, $comparison = null) { - if ($orderProduct instanceof OrderProduct) { + if ($orderProduct instanceof \Thelia\Model\OrderProduct) { return $this - ->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison); - } elseif ($orderProduct instanceof PropelObjectCollection) { + ->addUsingAlias(OrderFeatureTableMap::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison); + } elseif ($orderProduct instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderFeatureTableMap::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrderProduct() only accepts arguments of type OrderProduct or PropelCollection'); + throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection'); } } @@ -513,7 +495,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * @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 + * @return ChildOrderFeatureQuery The current query, for fluid interface */ public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -542,7 +524,7 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria /** * Use the OrderProduct relation OrderProduct object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -560,19 +542,94 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria /** * Exclude object from result * - * @param OrderFeature $orderFeature Object to remove from the list of results + * @param ChildOrderFeature $orderFeature Object to remove from the list of results * - * @return OrderFeatureQuery The current query, for fluid interface + * @return ChildOrderFeatureQuery The current query, for fluid interface */ public function prune($orderFeature = null) { if ($orderFeature) { - $this->addUsingAlias(OrderFeaturePeer::ID, $orderFeature->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(OrderFeatureTableMap::ID, $orderFeature->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the order_feature table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderFeatureTableMap::clearInstancePool(); + OrderFeatureTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderFeature or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderFeature object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderFeatureTableMap::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(); + + + OrderFeatureTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderFeatureTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -580,31 +637,11 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return OrderFeatureQuery The current query, for fluid interface + * @return ChildOrderFeatureQuery 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); + return $this->addUsingAlias(OrderFeatureTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -612,30 +649,51 @@ abstract class BaseOrderFeatureQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return OrderFeatureQuery The current query, for fluid interface + * @return ChildOrderFeatureQuery 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); + return $this->addUsingAlias(OrderFeatureTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderFeatureQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderFeatureTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderFeatureQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderFeatureTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return OrderFeatureQuery The current query, for fluid interface + * @return ChildOrderFeatureQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(OrderFeaturePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(OrderFeatureTableMap::CREATED_AT); } /** * Order by create date asc * - * @return OrderFeatureQuery The current query, for fluid interface + * @return ChildOrderFeatureQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(OrderFeaturePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(OrderFeatureTableMap::CREATED_AT); } -} + +} // OrderFeatureQuery diff --git a/core/lib/Thelia/Model/om/BaseOrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php old mode 100755 new mode 100644 similarity index 52% rename from core/lib/Thelia/Model/om/BaseOrderProduct.php rename to core/lib/Thelia/Model/Base/OrderProduct.php index 19c1993bc..b448e4e0c --- a/core/lib/Thelia/Model/om/BaseOrderProduct.php +++ b/core/lib/Thelia/Model/Base/OrderProduct.php @@ -1,55 +1,63 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderProduct instance. If + * obj is an instance of OrderProduct, delegates to + * equals(OrderProduct). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderProduct The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderProduct The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [order_id] column value. * - * @return int + * @return int */ public function getOrderId() { + return $this->order_id; } /** * Get the [product_ref] column value. * - * @return string + * @return string */ public function getProductRef() { + return $this->product_ref; } /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { + return $this->title; } /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { + return $this->description; } /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { + return $this->chapo; } /** * Get the [quantity] column value. * - * @return double + * @return double */ public function getQuantity() { + return $this->quantity; } /** * Get the [price] column value. * - * @return double + * @return double */ public function getPrice() { + return $this->price; } /** * Get the [tax] column value. * - * @return double + * @return double */ public function getTax() { + return $this->tax; } /** * Get the [parent] column value. * - * @return int + * @return int */ public function getParent() { + return $this->parent; } @@ -264,97 +524,57 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = OrderProductPeer::ID; + $this->modifiedColumns[] = OrderProductTableMap::ID; } @@ -364,18 +584,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Set the value of [order_id] column. * - * @param int $v new value - * @return OrderProduct The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setOrderId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->order_id !== $v) { $this->order_id = $v; - $this->modifiedColumns[] = OrderProductPeer::ORDER_ID; + $this->modifiedColumns[] = OrderProductTableMap::ORDER_ID; } if ($this->aOrder !== null && $this->aOrder->getId() !== $v) { @@ -389,18 +609,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Set the value of [product_ref] column. * - * @param string $v new value - * @return OrderProduct The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setProductRef($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->product_ref !== $v) { $this->product_ref = $v; - $this->modifiedColumns[] = OrderProductPeer::PRODUCT_REF; + $this->modifiedColumns[] = OrderProductTableMap::PRODUCT_REF; } @@ -410,18 +630,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return OrderProduct The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setTitle($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->title !== $v) { $this->title = $v; - $this->modifiedColumns[] = OrderProductPeer::TITLE; + $this->modifiedColumns[] = OrderProductTableMap::TITLE; } @@ -431,18 +651,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return OrderProduct The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setDescription($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->description !== $v) { $this->description = $v; - $this->modifiedColumns[] = OrderProductPeer::DESCRIPTION; + $this->modifiedColumns[] = OrderProductTableMap::DESCRIPTION; } @@ -452,18 +672,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return OrderProduct The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setChapo($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->chapo !== $v) { $this->chapo = $v; - $this->modifiedColumns[] = OrderProductPeer::CHAPO; + $this->modifiedColumns[] = OrderProductTableMap::CHAPO; } @@ -473,18 +693,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Set the value of [quantity] column. * - * @param double $v new value - * @return OrderProduct The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setQuantity($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->quantity !== $v) { $this->quantity = $v; - $this->modifiedColumns[] = OrderProductPeer::QUANTITY; + $this->modifiedColumns[] = OrderProductTableMap::QUANTITY; } @@ -494,18 +714,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Set the value of [price] column. * - * @param double $v new value - * @return OrderProduct The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setPrice($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->price !== $v) { $this->price = $v; - $this->modifiedColumns[] = OrderProductPeer::PRICE; + $this->modifiedColumns[] = OrderProductTableMap::PRICE; } @@ -515,18 +735,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Set the value of [tax] column. * - * @param double $v new value - * @return OrderProduct The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setTax($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->tax !== $v) { $this->tax = $v; - $this->modifiedColumns[] = OrderProductPeer::TAX; + $this->modifiedColumns[] = OrderProductTableMap::TAX; } @@ -536,18 +756,18 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Set the value of [parent] column. * - * @param int $v new value - * @return OrderProduct The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setParent($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->parent !== $v) { $this->parent = $v; - $this->modifiedColumns[] = OrderProductPeer::PARENT; + $this->modifiedColumns[] = OrderProductTableMap::PARENT; } @@ -557,19 +777,17 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderProductTableMap::CREATED_AT; } } // if either are not null @@ -580,19 +798,17 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderProductTableMap::UPDATED_AT; } } // if either are not null @@ -610,7 +826,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -622,28 +838,62 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderProductTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderProductTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderProductTableMap::translateFieldName('ProductRef', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderProductTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; + $this->quantity = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; + $this->price = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderProductTableMap::translateFieldName('Tax', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $this->parent = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -651,11 +901,11 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 12; // 12 = OrderProductPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 12; // 12 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating OrderProduct object", $e); + throw new PropelException("Error populating \Thelia\Model\OrderProduct object", 0, $e); } } @@ -674,7 +924,6 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) { $this->aOrder = null; } @@ -685,12 +934,12 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -701,19 +950,19 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(OrderProductTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildOrderProductQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -726,26 +975,25 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see OrderProduct::setDeleted() + * @see OrderProduct::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = OrderProductQuery::create() + $deleteQuery = ChildOrderProductQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -770,20 +1018,19 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -793,16 +1040,16 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(OrderProductPeer::CREATED_AT)) { + if (!$this->isColumnModified(OrderProductTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(OrderProductPeer::UPDATED_AT)) { + if (!$this->isColumnModified(OrderProductTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderProductPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(OrderProductTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -814,7 +1061,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - OrderProductPeer::addInstanceToPool($this); + OrderProductTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -833,19 +1080,19 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -869,15 +1116,15 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent if ($this->orderFeaturesScheduledForDeletion !== null) { if (!$this->orderFeaturesScheduledForDeletion->isEmpty()) { - OrderFeatureQuery::create() + \Thelia\Model\OrderFeatureQuery::create() ->filterByPrimaryKeys($this->orderFeaturesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->orderFeaturesScheduledForDeletion = null; } } - if ($this->collOrderFeatures !== null) { - foreach ($this->collOrderFeatures as $referrerFK) { + if ($this->collOrderFeatures !== null) { + foreach ($this->collOrderFeatures as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -894,61 +1141,61 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = OrderProductPeer::ID; + $this->modifiedColumns[] = OrderProductTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderProductPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(OrderProductTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(OrderProductPeer::ORDER_ID)) { - $modifiedColumns[':p' . $index++] = '`order_id`'; + if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_ID'; } - if ($this->isColumnModified(OrderProductPeer::PRODUCT_REF)) { - $modifiedColumns[':p' . $index++] = '`product_ref`'; + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_REF'; } - if ($this->isColumnModified(OrderProductPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; + if ($this->isColumnModified(OrderProductTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; } - if ($this->isColumnModified(OrderProductPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; + if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } - if ($this->isColumnModified(OrderProductPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; + if ($this->isColumnModified(OrderProductTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; } - if ($this->isColumnModified(OrderProductPeer::QUANTITY)) { - $modifiedColumns[':p' . $index++] = '`quantity`'; + if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) { + $modifiedColumns[':p' . $index++] = 'QUANTITY'; } - if ($this->isColumnModified(OrderProductPeer::PRICE)) { - $modifiedColumns[':p' . $index++] = '`price`'; + if ($this->isColumnModified(OrderProductTableMap::PRICE)) { + $modifiedColumns[':p' . $index++] = 'PRICE'; } - if ($this->isColumnModified(OrderProductPeer::TAX)) { - $modifiedColumns[':p' . $index++] = '`tax`'; + if ($this->isColumnModified(OrderProductTableMap::TAX)) { + $modifiedColumns[':p' . $index++] = 'TAX'; } - if ($this->isColumnModified(OrderProductPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`parent`'; + if ($this->isColumnModified(OrderProductTableMap::PARENT)) { + $modifiedColumns[':p' . $index++] = 'PARENT'; } - if ($this->isColumnModified(OrderProductPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(OrderProductPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `order_product` (%s) VALUES (%s)', + 'INSERT INTO order_product (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -957,54 +1204,54 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`order_id`': + case 'ORDER_ID': $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT); break; - case '`product_ref`': + case 'PRODUCT_REF': $stmt->bindValue($identifier, $this->product_ref, PDO::PARAM_STR); break; - case '`title`': + case 'TITLE': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`description`': + case 'DESCRIPTION': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`chapo`': + case 'CHAPO': $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); break; - case '`quantity`': + case 'QUANTITY': $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR); break; - case '`price`': + case 'PRICE': $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); break; - case '`tax`': + case 'TAX': $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR); break; - case '`parent`': + case 'PARENT': $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -1014,124 +1261,32 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = OrderProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1141,7 +1296,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1195,22 +1350,22 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = OrderProductTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getOrderId(), @@ -1225,6 +1380,12 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $keys[10] => $this->getCreatedAt(), $keys[11] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aOrder) { $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -1240,27 +1401,27 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = OrderProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1314,17 +1475,17 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = OrderProductPeer::getFieldNames($keyType); + $keys = OrderProductTableMap::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]]); @@ -1347,20 +1508,20 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(OrderProductPeer::DATABASE_NAME); + $criteria = new Criteria(OrderProductTableMap::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); + if ($this->isColumnModified(OrderProductTableMap::ID)) $criteria->add(OrderProductTableMap::ID, $this->id); + if ($this->isColumnModified(OrderProductTableMap::ORDER_ID)) $criteria->add(OrderProductTableMap::ORDER_ID, $this->order_id); + if ($this->isColumnModified(OrderProductTableMap::PRODUCT_REF)) $criteria->add(OrderProductTableMap::PRODUCT_REF, $this->product_ref); + if ($this->isColumnModified(OrderProductTableMap::TITLE)) $criteria->add(OrderProductTableMap::TITLE, $this->title); + if ($this->isColumnModified(OrderProductTableMap::DESCRIPTION)) $criteria->add(OrderProductTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(OrderProductTableMap::CHAPO)) $criteria->add(OrderProductTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(OrderProductTableMap::QUANTITY)) $criteria->add(OrderProductTableMap::QUANTITY, $this->quantity); + if ($this->isColumnModified(OrderProductTableMap::PRICE)) $criteria->add(OrderProductTableMap::PRICE, $this->price); + if ($this->isColumnModified(OrderProductTableMap::TAX)) $criteria->add(OrderProductTableMap::TAX, $this->tax); + if ($this->isColumnModified(OrderProductTableMap::PARENT)) $criteria->add(OrderProductTableMap::PARENT, $this->parent); + if ($this->isColumnModified(OrderProductTableMap::CREATED_AT)) $criteria->add(OrderProductTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderProductTableMap::UPDATED_AT)) $criteria->add(OrderProductTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1375,15 +1536,15 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(OrderProductPeer::DATABASE_NAME); - $criteria->add(OrderProductPeer::ID, $this->id); + $criteria = new Criteria(OrderProductTableMap::DATABASE_NAME); + $criteria->add(OrderProductTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1393,7 +1554,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1417,9 +1578,9 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1436,12 +1597,10 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1449,8 +1608,6 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1467,8 +1624,8 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\OrderProduct Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1482,31 +1639,13 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildOrder object. * - * 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) + * @param ChildOrder $v + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) * @throws PropelException */ - public function setOrder(Order $v = null) + public function setOrder(ChildOrder $v = null) { if ($v === null) { $this->setOrderId(NULL); @@ -1517,7 +1656,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $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 this object has already been added to the ChildOrder object, it will not be re-added. if ($v !== null) { $v->addOrderProduct($this); } @@ -1528,17 +1667,16 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** - * Get the associated Order object + * Get the associated ChildOrder object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Order The associated Order object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrder The associated ChildOrder object. * @throws PropelException */ - public function getOrder(PropelPDO $con = null, $doQuery = true) + public function getOrder(ConnectionInterface $con = null) { - if ($this->aOrder === null && ($this->order_id !== null) && $doQuery) { - $this->aOrder = OrderQuery::create()->findPk($this->order_id, $con); + if ($this->aOrder === null && ($this->order_id !== null)) { + $this->aOrder = ChildOrderQuery::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 @@ -1557,13 +1695,13 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('OrderFeature' == $relationName) { - $this->initOrderFeatures(); + return $this->initOrderFeatures(); } } @@ -1573,21 +1711,16 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addOrderFeatures() */ public function clearOrderFeatures() { - $this->collOrderFeatures = null; // important to set this to null since that means it is uninitialized - $this->collOrderFeaturesPartial = null; - - return $this; + $this->collOrderFeatures = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collOrderFeatures collection loaded partially - * - * @return void + * Reset is the collOrderFeatures collection loaded partially. */ public function resetPartialOrderFeatures($v = true) { @@ -1601,7 +1734,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1611,25 +1744,25 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent if (null !== $this->collOrderFeatures && !$overrideExisting) { return; } - $this->collOrderFeatures = new PropelObjectCollection(); - $this->collOrderFeatures->setModel('OrderFeature'); + $this->collOrderFeatures = new ObjectCollection(); + $this->collOrderFeatures->setModel('\Thelia\Model\OrderFeature'); } /** - * Gets an array of OrderFeature objects which contain a foreign key that references this object. + * Gets an array of ChildOrderFeature objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildOrderProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrderFeature[] List of ChildOrderFeature objects * @throws PropelException */ - public function getOrderFeatures($criteria = null, PropelPDO $con = null) + public function getOrderFeatures($criteria = null, ConnectionInterface $con = null) { $partial = $this->collOrderFeaturesPartial && !$this->isNew(); if (null === $this->collOrderFeatures || null !== $criteria || $partial) { @@ -1637,29 +1770,31 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent // return empty collection $this->initOrderFeatures(); } else { - $collOrderFeatures = OrderFeatureQuery::create(null, $criteria) + $collOrderFeatures = ChildOrderFeatureQuery::create(null, $criteria) ->filterByOrderProduct($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collOrderFeaturesPartial && count($collOrderFeatures)) { - $this->initOrderFeatures(false); + $this->initOrderFeatures(false); - foreach($collOrderFeatures as $obj) { - if (false == $this->collOrderFeatures->contains($obj)) { - $this->collOrderFeatures->append($obj); + foreach ($collOrderFeatures as $obj) { + if (false == $this->collOrderFeatures->contains($obj)) { + $this->collOrderFeatures->append($obj); + } } - } - $this->collOrderFeaturesPartial = true; + $this->collOrderFeaturesPartial = true; } $collOrderFeatures->getInternalIterator()->rewind(); + return $collOrderFeatures; } - if($partial && $this->collOrderFeatures) { - foreach($this->collOrderFeatures as $obj) { - if($obj->isNew()) { + if ($partial && $this->collOrderFeatures) { + foreach ($this->collOrderFeatures as $obj) { + if ($obj->isNew()) { $collOrderFeatures[] = $obj; } } @@ -1679,15 +1814,16 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $orderFeatures A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrderProduct The current object (for fluent API support) */ - public function setOrderFeatures(PropelCollection $orderFeatures, PropelPDO $con = null) + public function setOrderFeatures(Collection $orderFeatures, ConnectionInterface $con = null) { $orderFeaturesToDelete = $this->getOrderFeatures(new Criteria(), $con)->diff($orderFeatures); - $this->orderFeaturesScheduledForDeletion = unserialize(serialize($orderFeaturesToDelete)); + + $this->orderFeaturesScheduledForDeletion = $orderFeaturesToDelete; foreach ($orderFeaturesToDelete as $orderFeatureRemoved) { $orderFeatureRemoved->setOrderProduct(null); @@ -1707,13 +1843,13 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * Returns the number of related OrderFeature objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related OrderFeature objects. * @throws PropelException */ - public function countOrderFeatures(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countOrderFeatures(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collOrderFeaturesPartial && !$this->isNew(); if (null === $this->collOrderFeatures || null !== $criteria || $partial) { @@ -1721,10 +1857,11 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getOrderFeatures()); } - $query = OrderFeatureQuery::create(null, $criteria); + + $query = ChildOrderFeatureQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1738,18 +1875,19 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent } /** - * Method called to associate a OrderFeature object to this object - * through the OrderFeature foreign key attribute. + * Method called to associate a ChildOrderFeature object to this object + * through the ChildOrderFeature foreign key attribute. * - * @param OrderFeature $l OrderFeature - * @return OrderProduct The current object (for fluent API support) + * @param ChildOrderFeature $l ChildOrderFeature + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) */ - public function addOrderFeature(OrderFeature $l) + public function addOrderFeature(ChildOrderFeature $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); } @@ -1758,7 +1896,7 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent } /** - * @param OrderFeature $orderFeature The orderFeature object to add. + * @param OrderFeature $orderFeature The orderFeature object to add. */ protected function doAddOrderFeature($orderFeature) { @@ -1767,8 +1905,8 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent } /** - * @param OrderFeature $orderFeature The orderFeature object to remove. - * @return OrderProduct The current object (for fluent API support) + * @param OrderFeature $orderFeature The orderFeature object to remove. + * @return ChildOrderProduct The current object (for fluent API support) */ public function removeOrderFeature($orderFeature) { @@ -1803,8 +1941,6 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1816,27 +1952,21 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { 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) { + if ($this->collOrderFeatures instanceof Collection) { $this->collOrderFeatures->clearIterator(); } $this->collOrderFeatures = null; @@ -1844,23 +1974,13 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(OrderProductTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1868,13 +1988,131 @@ abstract class BaseOrderProduct extends BaseObject implements Persistent /** * 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) + * @return ChildOrderProduct The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = OrderProductPeer::UPDATED_AT; + $this->modifiedColumns[] = OrderProductTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php b/core/lib/Thelia/Model/Base/OrderProductQuery.php old mode 100755 new mode 100644 similarity index 54% rename from core/lib/Thelia/Model/om/BaseOrderProductQuery.php rename to core/lib/Thelia/Model/Base/OrderProductQuery.php index b93c39cce..b007c89e1 --- a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php +++ b/core/lib/Thelia/Model/Base/OrderProductQuery.php @@ -1,124 +1,123 @@ setModelAlias($modelAlias); } @@ -139,21 +138,21 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return OrderProduct|OrderProduct[]|mixed the result, formatted by the current formatter + * @return ChildOrderProduct|array|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 + if ((null !== ($obj = OrderProductTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(OrderProductTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -165,46 +164,31 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return OrderProduct A model object, or null if the key is not found - * @throws PropelException + * @return ChildOrderProduct A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new OrderProduct(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderProduct(); $obj->hydrate($row); - OrderProductPeer::addInstanceToPool($obj, (string) $key); + OrderProductTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -215,19 +199,19 @@ abstract class BaseOrderProductQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return OrderProduct|OrderProduct[]|mixed the result, formatted by the current formatter + * @return ChildOrderProduct|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -236,22 +220,22 @@ abstract class BaseOrderProductQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|OrderProduct[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -259,12 +243,12 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return OrderProductQuery The current query, for fluid interface + * @return ChildOrderProductQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(OrderProductPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(OrderProductTableMap::ID, $key, Criteria::EQUAL); } /** @@ -272,12 +256,12 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return OrderProductQuery The current query, for fluid interface + * @return ChildOrderProductQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(OrderProductPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(OrderProductTableMap::ID, $keys, Criteria::IN); } /** @@ -287,8 +271,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -297,18 +280,18 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery 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); + $this->addUsingAlias(OrderProductTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(OrderProductPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderProductTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -319,7 +302,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::ID, $id, $comparison); + return $this->addUsingAlias(OrderProductTableMap::ID, $id, $comparison); } /** @@ -329,8 +312,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $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 + * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12 * * * @see filterByOrder() @@ -341,18 +323,18 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery 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); + $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($orderId['max'])) { - $this->addUsingAlias(OrderProductPeer::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -363,7 +345,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::ORDER_ID, $orderId, $comparison); + return $this->addUsingAlias(OrderProductTableMap::ORDER_ID, $orderId, $comparison); } /** @@ -379,7 +361,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery The current query, for fluid interface */ public function filterByProductRef($productRef = null, $comparison = null) { @@ -392,7 +374,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::PRODUCT_REF, $productRef, $comparison); + return $this->addUsingAlias(OrderProductTableMap::PRODUCT_REF, $productRef, $comparison); } /** @@ -408,7 +390,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -421,7 +403,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(OrderProductTableMap::TITLE, $title, $comparison); } /** @@ -437,7 +419,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -450,7 +432,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(OrderProductTableMap::DESCRIPTION, $description, $comparison); } /** @@ -466,7 +448,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -479,7 +461,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison); } /** @@ -489,8 +471,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $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 + * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12 * * * @param mixed $quantity The value to use as filter. @@ -499,18 +480,18 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery 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); + $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($quantity['max'])) { - $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -521,7 +502,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity, $comparison); + return $this->addUsingAlias(OrderProductTableMap::QUANTITY, $quantity, $comparison); } /** @@ -531,8 +512,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $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 + * $query->filterByPrice(array('min' => 12)); // WHERE price > 12 * * * @param mixed $price The value to use as filter. @@ -541,18 +521,18 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery 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); + $this->addUsingAlias(OrderProductTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($price['max'])) { - $this->addUsingAlias(OrderProductPeer::PRICE, $price['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderProductTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -563,7 +543,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::PRICE, $price, $comparison); + return $this->addUsingAlias(OrderProductTableMap::PRICE, $price, $comparison); } /** @@ -573,8 +553,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $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 + * $query->filterByTax(array('min' => 12)); // WHERE tax > 12 * * * @param mixed $tax The value to use as filter. @@ -583,18 +562,18 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery 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); + $this->addUsingAlias(OrderProductTableMap::TAX, $tax['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($tax['max'])) { - $this->addUsingAlias(OrderProductPeer::TAX, $tax['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderProductTableMap::TAX, $tax['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -605,7 +584,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::TAX, $tax, $comparison); + return $this->addUsingAlias(OrderProductTableMap::TAX, $tax, $comparison); } /** @@ -615,8 +594,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * $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 + * $query->filterByParent(array('min' => 12)); // WHERE parent > 12 * * * @param mixed $parent The value to use as filter. @@ -625,18 +603,18 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery 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); + $this->addUsingAlias(OrderProductTableMap::PARENT, $parent['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($parent['max'])) { - $this->addUsingAlias(OrderProductPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderProductTableMap::PARENT, $parent['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -647,7 +625,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::PARENT, $parent, $comparison); + return $this->addUsingAlias(OrderProductTableMap::PARENT, $parent, $comparison); } /** @@ -668,18 +646,18 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery 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); + $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -690,7 +668,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(OrderProductTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -711,18 +689,18 @@ abstract class BaseOrderProductQuery extends ModelCriteria * 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 + * @return ChildOrderProductQuery 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); + $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -733,32 +711,31 @@ abstract class BaseOrderProductQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Order object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Order|ObjectCollection $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. + * @return ChildOrderProductQuery The current query, for fluid interface */ public function filterByOrder($order, $comparison = null) { - if ($order instanceof Order) { + if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(OrderProductPeer::ORDER_ID, $order->getId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { + ->addUsingAlias(OrderProductTableMap::ORDER_ID, $order->getId(), $comparison); + } elseif ($order instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderProductPeer::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderProductTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); + throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); } } @@ -768,7 +745,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * @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 + * @return ChildOrderProductQuery The current query, for fluid interface */ public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -797,7 +774,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria /** * Use the Order relation Order object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -813,26 +790,25 @@ abstract class BaseOrderProductQuery extends ModelCriteria } /** - * Filter the query by a related OrderFeature object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\OrderFeature|ObjectCollection $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. + * @return ChildOrderProductQuery The current query, for fluid interface */ public function filterByOrderFeature($orderFeature, $comparison = null) { - if ($orderFeature instanceof OrderFeature) { + if ($orderFeature instanceof \Thelia\Model\OrderFeature) { return $this - ->addUsingAlias(OrderProductPeer::ID, $orderFeature->getOrderProductId(), $comparison); - } elseif ($orderFeature instanceof PropelObjectCollection) { + ->addUsingAlias(OrderProductTableMap::ID, $orderFeature->getOrderProductId(), $comparison); + } elseif ($orderFeature instanceof ObjectCollection) { return $this ->useOrderFeatureQuery() ->filterByPrimaryKeys($orderFeature->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderFeature() only accepts arguments of type OrderFeature or PropelCollection'); + throw new PropelException('filterByOrderFeature() only accepts arguments of type \Thelia\Model\OrderFeature or Collection'); } } @@ -842,7 +818,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria * @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 + * @return ChildOrderProductQuery The current query, for fluid interface */ public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -871,7 +847,7 @@ abstract class BaseOrderProductQuery extends ModelCriteria /** * Use the OrderFeature relation OrderFeature object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -889,19 +865,94 @@ abstract class BaseOrderProductQuery extends ModelCriteria /** * Exclude object from result * - * @param OrderProduct $orderProduct Object to remove from the list of results + * @param ChildOrderProduct $orderProduct Object to remove from the list of results * - * @return OrderProductQuery The current query, for fluid interface + * @return ChildOrderProductQuery The current query, for fluid interface */ public function prune($orderProduct = null) { if ($orderProduct) { - $this->addUsingAlias(OrderProductPeer::ID, $orderProduct->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(OrderProductTableMap::ID, $orderProduct->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the order_product table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderProductTableMap::clearInstancePool(); + OrderProductTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderProduct or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderProduct object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderProductTableMap::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(); + + + OrderProductTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderProductTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -909,31 +960,11 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return OrderProductQuery The current query, for fluid interface + * @return ChildOrderProductQuery 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); + return $this->addUsingAlias(OrderProductTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -941,30 +972,51 @@ abstract class BaseOrderProductQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return OrderProductQuery The current query, for fluid interface + * @return ChildOrderProductQuery 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); + return $this->addUsingAlias(OrderProductTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderProductTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderProductTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return OrderProductQuery The current query, for fluid interface + * @return ChildOrderProductQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(OrderProductPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(OrderProductTableMap::CREATED_AT); } /** * Order by create date asc * - * @return OrderProductQuery The current query, for fluid interface + * @return ChildOrderProductQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(OrderProductPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(OrderProductTableMap::CREATED_AT); } -} + +} // OrderProductQuery diff --git a/core/lib/Thelia/Model/om/BaseOrderQuery.php b/core/lib/Thelia/Model/Base/OrderQuery.php old mode 100755 new mode 100644 similarity index 59% rename from core/lib/Thelia/Model/om/BaseOrderQuery.php rename to core/lib/Thelia/Model/Base/OrderQuery.php index c0e630548..bdff793a8 --- a/core/lib/Thelia/Model/om/BaseOrderQuery.php +++ b/core/lib/Thelia/Model/Base/OrderQuery.php @@ -1,172 +1,167 @@ setModelAlias($modelAlias); } @@ -187,21 +182,21 @@ abstract class BaseOrderQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Order|Order[]|mixed the result, formatted by the current formatter + * @return ChildOrder|array|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 + if ((null !== ($obj = OrderTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(OrderTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -213,46 +208,31 @@ abstract class BaseOrderQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Order A model object, or null if the key is not found - * @throws PropelException + * @return ChildOrder A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Order(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrder(); $obj->hydrate($row); - OrderPeer::addInstanceToPool($obj, (string) $key); + OrderTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -263,19 +243,19 @@ abstract class BaseOrderQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Order|Order[]|mixed the result, formatted by the current formatter + * @return ChildOrder|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -284,22 +264,22 @@ abstract class BaseOrderQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Order[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -307,12 +287,12 @@ abstract class BaseOrderQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return OrderQuery The current query, for fluid interface + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(OrderPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(OrderTableMap::ID, $key, Criteria::EQUAL); } /** @@ -320,12 +300,12 @@ abstract class BaseOrderQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return OrderQuery The current query, for fluid interface + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(OrderPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(OrderTableMap::ID, $keys, Criteria::IN); } /** @@ -335,8 +315,7 @@ abstract class BaseOrderQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -345,18 +324,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(OrderPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -367,7 +346,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::ID, $id, $comparison); + return $this->addUsingAlias(OrderTableMap::ID, $id, $comparison); } /** @@ -383,7 +362,7 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByRef($ref = null, $comparison = null) { @@ -396,7 +375,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::REF, $ref, $comparison); + return $this->addUsingAlias(OrderTableMap::REF, $ref, $comparison); } /** @@ -406,8 +385,7 @@ abstract class BaseOrderQuery extends ModelCriteria * * $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 + * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id > 12 * * * @see filterByCustomer() @@ -418,18 +396,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($customerId['max'])) { - $this->addUsingAlias(OrderPeer::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -440,7 +418,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::CUSTOMER_ID, $customerId, $comparison); + return $this->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customerId, $comparison); } /** @@ -450,8 +428,7 @@ abstract class BaseOrderQuery extends ModelCriteria * * $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 + * $query->filterByAddressInvoice(array('min' => 12)); // WHERE address_invoice > 12 * * * @see filterByOrderAddressRelatedByAddressInvoice() @@ -462,18 +439,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($addressInvoice['max'])) { - $this->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $addressInvoice['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -484,7 +461,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $addressInvoice, $comparison); + return $this->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $addressInvoice, $comparison); } /** @@ -494,8 +471,7 @@ abstract class BaseOrderQuery extends ModelCriteria * * $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 + * $query->filterByAddressDelivery(array('min' => 12)); // WHERE address_delivery > 12 * * * @see filterByOrderAddressRelatedByAddressDelivery() @@ -506,18 +482,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($addressDelivery['max'])) { - $this->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $addressDelivery['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -528,7 +504,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $addressDelivery, $comparison); + return $this->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $addressDelivery, $comparison); } /** @@ -549,18 +525,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::INVOICE_DATE, $invoiceDate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($invoiceDate['max'])) { - $this->addUsingAlias(OrderPeer::INVOICE_DATE, $invoiceDate['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::INVOICE_DATE, $invoiceDate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -571,7 +547,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::INVOICE_DATE, $invoiceDate, $comparison); + return $this->addUsingAlias(OrderTableMap::INVOICE_DATE, $invoiceDate, $comparison); } /** @@ -581,8 +557,7 @@ abstract class BaseOrderQuery extends ModelCriteria * * $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 + * $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id > 12 * * * @see filterByCurrency() @@ -593,18 +568,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::CURRENCY_ID, $currencyId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($currencyId['max'])) { - $this->addUsingAlias(OrderPeer::CURRENCY_ID, $currencyId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::CURRENCY_ID, $currencyId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -615,7 +590,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::CURRENCY_ID, $currencyId, $comparison); + return $this->addUsingAlias(OrderTableMap::CURRENCY_ID, $currencyId, $comparison); } /** @@ -625,8 +600,7 @@ abstract class BaseOrderQuery extends ModelCriteria * * $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 + * $query->filterByCurrencyRate(array('min' => 12)); // WHERE currency_rate > 12 * * * @param mixed $currencyRate The value to use as filter. @@ -635,18 +609,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::CURRENCY_RATE, $currencyRate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($currencyRate['max'])) { - $this->addUsingAlias(OrderPeer::CURRENCY_RATE, $currencyRate['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::CURRENCY_RATE, $currencyRate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -657,7 +631,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::CURRENCY_RATE, $currencyRate, $comparison); + return $this->addUsingAlias(OrderTableMap::CURRENCY_RATE, $currencyRate, $comparison); } /** @@ -673,7 +647,7 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByTransaction($transaction = null, $comparison = null) { @@ -686,7 +660,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::TRANSACTION, $transaction, $comparison); + return $this->addUsingAlias(OrderTableMap::TRANSACTION, $transaction, $comparison); } /** @@ -702,7 +676,7 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByDeliveryNum($deliveryNum = null, $comparison = null) { @@ -715,7 +689,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::DELIVERY_NUM, $deliveryNum, $comparison); + return $this->addUsingAlias(OrderTableMap::DELIVERY_NUM, $deliveryNum, $comparison); } /** @@ -731,7 +705,7 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByInvoice($invoice = null, $comparison = null) { @@ -744,7 +718,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::INVOICE, $invoice, $comparison); + return $this->addUsingAlias(OrderTableMap::INVOICE, $invoice, $comparison); } /** @@ -754,8 +728,7 @@ abstract class BaseOrderQuery extends ModelCriteria * * $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 + * $query->filterByPostage(array('min' => 12)); // WHERE postage > 12 * * * @param mixed $postage The value to use as filter. @@ -764,18 +737,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::POSTAGE, $postage['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($postage['max'])) { - $this->addUsingAlias(OrderPeer::POSTAGE, $postage['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::POSTAGE, $postage['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -786,7 +759,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::POSTAGE, $postage, $comparison); + return $this->addUsingAlias(OrderTableMap::POSTAGE, $postage, $comparison); } /** @@ -802,7 +775,7 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByPayment($payment = null, $comparison = null) { @@ -815,7 +788,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::PAYMENT, $payment, $comparison); + return $this->addUsingAlias(OrderTableMap::PAYMENT, $payment, $comparison); } /** @@ -831,7 +804,7 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByCarrier($carrier = null, $comparison = null) { @@ -844,7 +817,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::CARRIER, $carrier, $comparison); + return $this->addUsingAlias(OrderTableMap::CARRIER, $carrier, $comparison); } /** @@ -854,8 +827,7 @@ abstract class BaseOrderQuery extends ModelCriteria * * $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 + * $query->filterByStatusId(array('min' => 12)); // WHERE status_id > 12 * * * @see filterByOrderStatus() @@ -866,18 +838,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::STATUS_ID, $statusId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($statusId['max'])) { - $this->addUsingAlias(OrderPeer::STATUS_ID, $statusId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::STATUS_ID, $statusId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -888,7 +860,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::STATUS_ID, $statusId, $comparison); + return $this->addUsingAlias(OrderTableMap::STATUS_ID, $statusId, $comparison); } /** @@ -904,7 +876,7 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByLang($lang = null, $comparison = null) { @@ -917,7 +889,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::LANG, $lang, $comparison); + return $this->addUsingAlias(OrderTableMap::LANG, $lang, $comparison); } /** @@ -938,18 +910,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -960,7 +932,7 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(OrderTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -981,18 +953,18 @@ abstract class BaseOrderQuery extends ModelCriteria * 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 + * @return ChildOrderQuery 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); + $this->addUsingAlias(OrderTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -1003,32 +975,31 @@ abstract class BaseOrderQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(OrderTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Currency object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Currency|ObjectCollection $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. + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByCurrency($currency, $comparison = null) { - if ($currency instanceof Currency) { + if ($currency instanceof \Thelia\Model\Currency) { return $this - ->addUsingAlias(OrderPeer::CURRENCY_ID, $currency->getId(), $comparison); - } elseif ($currency instanceof PropelObjectCollection) { + ->addUsingAlias(OrderTableMap::CURRENCY_ID, $currency->getId(), $comparison); + } elseif ($currency instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderPeer::CURRENCY_ID, $currency->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderTableMap::CURRENCY_ID, $currency->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCurrency() only accepts arguments of type Currency or PropelCollection'); + throw new PropelException('filterByCurrency() only accepts arguments of type \Thelia\Model\Currency or Collection'); } } @@ -1038,7 +1009,7 @@ abstract class BaseOrderQuery extends ModelCriteria * @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 + * @return ChildOrderQuery The current query, for fluid interface */ public function joinCurrency($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1067,7 +1038,7 @@ abstract class BaseOrderQuery extends ModelCriteria /** * Use the Currency relation Currency object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1083,28 +1054,27 @@ abstract class BaseOrderQuery extends ModelCriteria } /** - * Filter the query by a related Customer object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Customer|ObjectCollection $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. + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByCustomer($customer, $comparison = null) { - if ($customer instanceof Customer) { + if ($customer instanceof \Thelia\Model\Customer) { return $this - ->addUsingAlias(OrderPeer::CUSTOMER_ID, $customer->getId(), $comparison); - } elseif ($customer instanceof PropelObjectCollection) { + ->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customer->getId(), $comparison); + } elseif ($customer instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderPeer::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderTableMap::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection'); + throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection'); } } @@ -1114,7 +1084,7 @@ abstract class BaseOrderQuery extends ModelCriteria * @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 + * @return ChildOrderQuery The current query, for fluid interface */ public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1143,7 +1113,7 @@ abstract class BaseOrderQuery extends ModelCriteria /** * Use the Customer relation Customer object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1159,28 +1129,27 @@ abstract class BaseOrderQuery extends ModelCriteria } /** - * Filter the query by a related OrderAddress object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\OrderAddress|ObjectCollection $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. + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByOrderAddressRelatedByAddressInvoice($orderAddress, $comparison = null) { - if ($orderAddress instanceof OrderAddress) { + if ($orderAddress instanceof \Thelia\Model\OrderAddress) { return $this - ->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $orderAddress->getId(), $comparison); - } elseif ($orderAddress instanceof PropelObjectCollection) { + ->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $orderAddress->getId(), $comparison); + } elseif ($orderAddress instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderTableMap::ADDRESS_INVOICE, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrderAddressRelatedByAddressInvoice() only accepts arguments of type OrderAddress or PropelCollection'); + throw new PropelException('filterByOrderAddressRelatedByAddressInvoice() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); } } @@ -1190,7 +1159,7 @@ abstract class BaseOrderQuery extends ModelCriteria * @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 + * @return ChildOrderQuery The current query, for fluid interface */ public function joinOrderAddressRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1219,7 +1188,7 @@ abstract class BaseOrderQuery extends ModelCriteria /** * Use the OrderAddressRelatedByAddressInvoice relation OrderAddress object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1235,28 +1204,27 @@ abstract class BaseOrderQuery extends ModelCriteria } /** - * Filter the query by a related OrderAddress object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\OrderAddress|ObjectCollection $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. + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByOrderAddressRelatedByAddressDelivery($orderAddress, $comparison = null) { - if ($orderAddress instanceof OrderAddress) { + if ($orderAddress instanceof \Thelia\Model\OrderAddress) { return $this - ->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $orderAddress->getId(), $comparison); - } elseif ($orderAddress instanceof PropelObjectCollection) { + ->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $orderAddress->getId(), $comparison); + } elseif ($orderAddress instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderTableMap::ADDRESS_DELIVERY, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrderAddressRelatedByAddressDelivery() only accepts arguments of type OrderAddress or PropelCollection'); + throw new PropelException('filterByOrderAddressRelatedByAddressDelivery() only accepts arguments of type \Thelia\Model\OrderAddress or Collection'); } } @@ -1266,7 +1234,7 @@ abstract class BaseOrderQuery extends ModelCriteria * @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 + * @return ChildOrderQuery The current query, for fluid interface */ public function joinOrderAddressRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1295,7 +1263,7 @@ abstract class BaseOrderQuery extends ModelCriteria /** * Use the OrderAddressRelatedByAddressDelivery relation OrderAddress object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1311,28 +1279,27 @@ abstract class BaseOrderQuery extends ModelCriteria } /** - * Filter the query by a related OrderStatus object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\OrderStatus|ObjectCollection $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. + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByOrderStatus($orderStatus, $comparison = null) { - if ($orderStatus instanceof OrderStatus) { + if ($orderStatus instanceof \Thelia\Model\OrderStatus) { return $this - ->addUsingAlias(OrderPeer::STATUS_ID, $orderStatus->getId(), $comparison); - } elseif ($orderStatus instanceof PropelObjectCollection) { + ->addUsingAlias(OrderTableMap::STATUS_ID, $orderStatus->getId(), $comparison); + } elseif ($orderStatus instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(OrderPeer::STATUS_ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(OrderTableMap::STATUS_ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByOrderStatus() only accepts arguments of type OrderStatus or PropelCollection'); + throw new PropelException('filterByOrderStatus() only accepts arguments of type \Thelia\Model\OrderStatus or Collection'); } } @@ -1342,7 +1309,7 @@ abstract class BaseOrderQuery extends ModelCriteria * @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 + * @return ChildOrderQuery The current query, for fluid interface */ public function joinOrderStatus($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1371,7 +1338,7 @@ abstract class BaseOrderQuery extends ModelCriteria /** * Use the OrderStatus relation OrderStatus object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1387,26 +1354,25 @@ abstract class BaseOrderQuery extends ModelCriteria } /** - * Filter the query by a related OrderProduct object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\OrderProduct|ObjectCollection $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. + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByOrderProduct($orderProduct, $comparison = null) { - if ($orderProduct instanceof OrderProduct) { + if ($orderProduct instanceof \Thelia\Model\OrderProduct) { return $this - ->addUsingAlias(OrderPeer::ID, $orderProduct->getOrderId(), $comparison); - } elseif ($orderProduct instanceof PropelObjectCollection) { + ->addUsingAlias(OrderTableMap::ID, $orderProduct->getOrderId(), $comparison); + } elseif ($orderProduct instanceof ObjectCollection) { return $this ->useOrderProductQuery() ->filterByPrimaryKeys($orderProduct->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderProduct() only accepts arguments of type OrderProduct or PropelCollection'); + throw new PropelException('filterByOrderProduct() only accepts arguments of type \Thelia\Model\OrderProduct or Collection'); } } @@ -1416,7 +1382,7 @@ abstract class BaseOrderQuery extends ModelCriteria * @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 + * @return ChildOrderQuery The current query, for fluid interface */ public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1445,7 +1411,7 @@ abstract class BaseOrderQuery extends ModelCriteria /** * Use the OrderProduct relation OrderProduct object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1461,26 +1427,25 @@ abstract class BaseOrderQuery extends ModelCriteria } /** - * Filter the query by a related CouponOrder object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\CouponOrder|ObjectCollection $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. + * @return ChildOrderQuery The current query, for fluid interface */ public function filterByCouponOrder($couponOrder, $comparison = null) { - if ($couponOrder instanceof CouponOrder) { + if ($couponOrder instanceof \Thelia\Model\CouponOrder) { return $this - ->addUsingAlias(OrderPeer::ID, $couponOrder->getOrderId(), $comparison); - } elseif ($couponOrder instanceof PropelObjectCollection) { + ->addUsingAlias(OrderTableMap::ID, $couponOrder->getOrderId(), $comparison); + } elseif ($couponOrder instanceof ObjectCollection) { return $this ->useCouponOrderQuery() ->filterByPrimaryKeys($couponOrder->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByCouponOrder() only accepts arguments of type CouponOrder or PropelCollection'); + throw new PropelException('filterByCouponOrder() only accepts arguments of type \Thelia\Model\CouponOrder or Collection'); } } @@ -1490,7 +1455,7 @@ abstract class BaseOrderQuery extends ModelCriteria * @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 + * @return ChildOrderQuery The current query, for fluid interface */ public function joinCouponOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1519,7 +1484,7 @@ abstract class BaseOrderQuery extends ModelCriteria /** * Use the CouponOrder relation CouponOrder object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1537,19 +1502,94 @@ abstract class BaseOrderQuery extends ModelCriteria /** * Exclude object from result * - * @param Order $order Object to remove from the list of results + * @param ChildOrder $order Object to remove from the list of results * - * @return OrderQuery The current query, for fluid interface + * @return ChildOrderQuery The current query, for fluid interface */ public function prune($order = null) { if ($order) { - $this->addUsingAlias(OrderPeer::ID, $order->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(OrderTableMap::ID, $order->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the order table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderTableMap::clearInstancePool(); + OrderTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrder or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrder object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderTableMap::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(); + + + OrderTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -1557,31 +1597,11 @@ abstract class BaseOrderQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return OrderQuery The current query, for fluid interface + * @return ChildOrderQuery 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); + return $this->addUsingAlias(OrderTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -1589,30 +1609,51 @@ abstract class BaseOrderQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return OrderQuery The current query, for fluid interface + * @return ChildOrderQuery 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); + return $this->addUsingAlias(OrderTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return OrderQuery The current query, for fluid interface + * @return ChildOrderQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(OrderPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(OrderTableMap::CREATED_AT); } /** * Order by create date asc * - * @return OrderQuery The current query, for fluid interface + * @return ChildOrderQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(OrderPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(OrderTableMap::CREATED_AT); } -} + +} // OrderQuery diff --git a/core/lib/Thelia/Model/om/BaseOrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseOrderStatus.php rename to core/lib/Thelia/Model/Base/OrderStatus.php index 2654069e2..15ce7fbf7 --- a/core/lib/Thelia/Model/om/BaseOrderStatus.php +++ b/core/lib/Thelia/Model/Base/OrderStatus.php @@ -1,55 +1,63 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderStatus instance. If + * obj is an instance of OrderStatus, delegates to + * equals(OrderStatus). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderStatus The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderStatus The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [code] column value. * - * @return string + * @return string */ public function getCode() { + return $this->code; } @@ -157,97 +409,57 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\OrderStatus The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = OrderStatusPeer::ID; + $this->modifiedColumns[] = OrderStatusTableMap::ID; } @@ -257,18 +469,18 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Set the value of [code] column. * - * @param string $v new value - * @return OrderStatus The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderStatus The current object (for fluent API support) */ public function setCode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->code !== $v) { $this->code = $v; - $this->modifiedColumns[] = OrderStatusPeer::CODE; + $this->modifiedColumns[] = OrderStatusTableMap::CODE; } @@ -278,19 +490,17 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderStatus The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = OrderStatusTableMap::CREATED_AT; } } // if either are not null @@ -301,19 +511,17 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\OrderStatus The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = OrderStatusTableMap::UPDATED_AT; } } // if either are not null @@ -331,7 +539,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -343,20 +551,38 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderStatusTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderStatusTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderStatusTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderStatusTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -364,11 +590,11 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = OrderStatusPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 4; // 4 = OrderStatusTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating OrderStatus object", $e); + throw new PropelException("Error populating \Thelia\Model\OrderStatus object", 0, $e); } } @@ -387,7 +613,6 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -395,12 +620,12 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -411,19 +636,19 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(OrderStatusTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildOrderStatusQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -437,26 +662,25 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see OrderStatus::setDeleted() + * @see OrderStatus::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = OrderStatusQuery::create() + $deleteQuery = ChildOrderStatusQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -481,20 +705,19 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -504,16 +727,16 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(OrderStatusPeer::CREATED_AT)) { + if (!$this->isColumnModified(OrderStatusTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(OrderStatusPeer::UPDATED_AT)) { + if (!$this->isColumnModified(OrderStatusTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderStatusPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(OrderStatusTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -525,7 +748,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - OrderStatusPeer::addInstanceToPool($this); + OrderStatusTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -544,12 +767,12 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -576,8 +799,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } } - if ($this->collOrders !== null) { - foreach ($this->collOrders as $referrerFK) { + if ($this->collOrders !== null) { + foreach ($this->collOrders as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -586,15 +809,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if ($this->orderStatusI18nsScheduledForDeletion !== null) { if (!$this->orderStatusI18nsScheduledForDeletion->isEmpty()) { - OrderStatusI18nQuery::create() + \Thelia\Model\OrderStatusI18nQuery::create() ->filterByPrimaryKeys($this->orderStatusI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->orderStatusI18nsScheduledForDeletion = null; } } - if ($this->collOrderStatusI18ns !== null) { - foreach ($this->collOrderStatusI18ns as $referrerFK) { + if ($this->collOrderStatusI18ns !== null) { + foreach ($this->collOrderStatusI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -611,37 +834,37 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = OrderStatusPeer::ID; + $this->modifiedColumns[] = OrderStatusTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderStatusPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderStatusTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderStatusPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(OrderStatusTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(OrderStatusPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; + if ($this->isColumnModified(OrderStatusTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(OrderStatusPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(OrderStatusTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(OrderStatusPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(OrderStatusTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `order_status` (%s) VALUES (%s)', + 'INSERT INTO order_status (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -650,30 +873,30 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`code`': + case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -683,120 +906,32 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = OrderStatusTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -806,7 +941,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -836,28 +971,34 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = OrderStatusTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), $keys[2] => $this->getCreatedAt(), $keys[3] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collOrders) { $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -873,27 +1014,27 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = OrderStatusTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -923,17 +1064,17 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = OrderStatusPeer::getFieldNames($keyType); + $keys = OrderStatusTableMap::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]]); @@ -948,12 +1089,12 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME); + $criteria = new Criteria(OrderStatusTableMap::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); + if ($this->isColumnModified(OrderStatusTableMap::ID)) $criteria->add(OrderStatusTableMap::ID, $this->id); + if ($this->isColumnModified(OrderStatusTableMap::CODE)) $criteria->add(OrderStatusTableMap::CODE, $this->code); + if ($this->isColumnModified(OrderStatusTableMap::CREATED_AT)) $criteria->add(OrderStatusTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(OrderStatusTableMap::UPDATED_AT)) $criteria->add(OrderStatusTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -968,15 +1109,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME); - $criteria->add(OrderStatusPeer::ID, $this->id); + $criteria = new Criteria(OrderStatusTableMap::DATABASE_NAME); + $criteria->add(OrderStatusTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -986,7 +1127,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1010,9 +1151,9 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1021,12 +1162,10 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1040,8 +1179,6 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1058,8 +1195,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\OrderStatus Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1072,40 +1209,22 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('Order' == $relationName) { - $this->initOrders(); + return $this->initOrders(); } if ('OrderStatusI18n' == $relationName) { - $this->initOrderStatusI18ns(); + return $this->initOrderStatusI18ns(); } } @@ -1115,21 +1234,16 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * This 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) + * @return void * @see addOrders() */ public function clearOrders() { - $this->collOrders = null; // important to set this to null since that means it is uninitialized - $this->collOrdersPartial = null; - - return $this; + $this->collOrders = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collOrders collection loaded partially - * - * @return void + * Reset is the collOrders collection loaded partially. */ public function resetPartialOrders($v = true) { @@ -1143,7 +1257,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1153,25 +1267,25 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if (null !== $this->collOrders && !$overrideExisting) { return; } - $this->collOrders = new PropelObjectCollection(); - $this->collOrders->setModel('Order'); + $this->collOrders = new ObjectCollection(); + $this->collOrders->setModel('\Thelia\Model\Order'); } /** - * Gets an array of Order objects which contain a foreign key that references this object. + * Gets an array of ChildOrder objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildOrderStatus is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrder[] List of ChildOrder objects * @throws PropelException */ - public function getOrders($criteria = null, PropelPDO $con = null) + public function getOrders($criteria = null, ConnectionInterface $con = null) { $partial = $this->collOrdersPartial && !$this->isNew(); if (null === $this->collOrders || null !== $criteria || $partial) { @@ -1179,29 +1293,31 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent // return empty collection $this->initOrders(); } else { - $collOrders = OrderQuery::create(null, $criteria) + $collOrders = ChildOrderQuery::create(null, $criteria) ->filterByOrderStatus($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collOrdersPartial && count($collOrders)) { - $this->initOrders(false); + $this->initOrders(false); - foreach($collOrders as $obj) { - if (false == $this->collOrders->contains($obj)) { - $this->collOrders->append($obj); + foreach ($collOrders as $obj) { + if (false == $this->collOrders->contains($obj)) { + $this->collOrders->append($obj); + } } - } - $this->collOrdersPartial = true; + $this->collOrdersPartial = true; } $collOrders->getInternalIterator()->rewind(); + return $collOrders; } - if($partial && $this->collOrders) { - foreach($this->collOrders as $obj) { - if($obj->isNew()) { + if ($partial && $this->collOrders) { + foreach ($this->collOrders as $obj) { + if ($obj->isNew()) { $collOrders[] = $obj; } } @@ -1221,15 +1337,16 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * It will 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) + * @param Collection $orders A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrderStatus The current object (for fluent API support) */ - public function setOrders(PropelCollection $orders, PropelPDO $con = null) + public function setOrders(Collection $orders, ConnectionInterface $con = null) { $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); - $this->ordersScheduledForDeletion = unserialize(serialize($ordersToDelete)); + + $this->ordersScheduledForDeletion = $ordersToDelete; foreach ($ordersToDelete as $orderRemoved) { $orderRemoved->setOrderStatus(null); @@ -1249,13 +1366,13 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Returns the number of related Order objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Order objects. * @throws PropelException */ - public function countOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collOrdersPartial && !$this->isNew(); if (null === $this->collOrders || null !== $criteria || $partial) { @@ -1263,10 +1380,11 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getOrders()); } - $query = OrderQuery::create(null, $criteria); + + $query = ChildOrderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1280,18 +1398,19 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. + * Method called to associate a ChildOrder object to this object + * through the ChildOrder foreign key attribute. * - * @param Order $l Order - * @return OrderStatus The current object (for fluent API support) + * @param ChildOrder $l ChildOrder + * @return \Thelia\Model\OrderStatus The current object (for fluent API support) */ - public function addOrder(Order $l) + public function addOrder(ChildOrder $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); } @@ -1300,7 +1419,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } /** - * @param Order $order The order object to add. + * @param Order $order The order object to add. */ protected function doAddOrder($order) { @@ -1309,8 +1428,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } /** - * @param Order $order The order object to remove. - * @return OrderStatus The current object (for fluent API support) + * @param Order $order The order object to remove. + * @return ChildOrderStatus The current object (for fluent API support) */ public function removeOrder($order) { @@ -1339,15 +1458,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinCurrency($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Currency', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Currency', $joinBehavior); return $this->getOrders($query, $con); } @@ -1364,15 +1483,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinCustomer($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('Customer', $joinBehavior); return $this->getOrders($query, $con); } @@ -1389,15 +1508,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByAddressInvoice', $joinBehavior); return $this->getOrders($query, $con); } @@ -1414,15 +1533,15 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildOrder[] List of ChildOrder objects */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $join_behavior); + $query = ChildOrderQuery::create(null, $criteria); + $query->joinWith('OrderAddressRelatedByAddressDelivery', $joinBehavior); return $this->getOrders($query, $con); } @@ -1433,21 +1552,16 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collOrderStatusI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collOrderStatusI18ns collection loaded partially - * - * @return void + * Reset is the collOrderStatusI18ns collection loaded partially. */ public function resetPartialOrderStatusI18ns($v = true) { @@ -1461,7 +1575,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1471,25 +1585,25 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent if (null !== $this->collOrderStatusI18ns && !$overrideExisting) { return; } - $this->collOrderStatusI18ns = new PropelObjectCollection(); - $this->collOrderStatusI18ns->setModel('OrderStatusI18n'); + $this->collOrderStatusI18ns = new ObjectCollection(); + $this->collOrderStatusI18ns->setModel('\Thelia\Model\OrderStatusI18n'); } /** - * Gets an array of OrderStatusI18n objects which contain a foreign key that references this object. + * Gets an array of ChildOrderStatusI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildOrderStatus is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildOrderStatusI18n[] List of ChildOrderStatusI18n objects * @throws PropelException */ - public function getOrderStatusI18ns($criteria = null, PropelPDO $con = null) + public function getOrderStatusI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collOrderStatusI18nsPartial && !$this->isNew(); if (null === $this->collOrderStatusI18ns || null !== $criteria || $partial) { @@ -1497,29 +1611,31 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent // return empty collection $this->initOrderStatusI18ns(); } else { - $collOrderStatusI18ns = OrderStatusI18nQuery::create(null, $criteria) + $collOrderStatusI18ns = ChildOrderStatusI18nQuery::create(null, $criteria) ->filterByOrderStatus($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collOrderStatusI18nsPartial && count($collOrderStatusI18ns)) { - $this->initOrderStatusI18ns(false); + $this->initOrderStatusI18ns(false); - foreach($collOrderStatusI18ns as $obj) { - if (false == $this->collOrderStatusI18ns->contains($obj)) { - $this->collOrderStatusI18ns->append($obj); + foreach ($collOrderStatusI18ns as $obj) { + if (false == $this->collOrderStatusI18ns->contains($obj)) { + $this->collOrderStatusI18ns->append($obj); + } } - } - $this->collOrderStatusI18nsPartial = true; + $this->collOrderStatusI18nsPartial = true; } $collOrderStatusI18ns->getInternalIterator()->rewind(); + return $collOrderStatusI18ns; } - if($partial && $this->collOrderStatusI18ns) { - foreach($this->collOrderStatusI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collOrderStatusI18ns) { + foreach ($this->collOrderStatusI18ns as $obj) { + if ($obj->isNew()) { $collOrderStatusI18ns[] = $obj; } } @@ -1539,15 +1655,19 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * It will 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) + * @param Collection $orderStatusI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildOrderStatus The current object (for fluent API support) */ - public function setOrderStatusI18ns(PropelCollection $orderStatusI18ns, PropelPDO $con = null) + public function setOrderStatusI18ns(Collection $orderStatusI18ns, ConnectionInterface $con = null) { $orderStatusI18nsToDelete = $this->getOrderStatusI18ns(new Criteria(), $con)->diff($orderStatusI18ns); - $this->orderStatusI18nsScheduledForDeletion = unserialize(serialize($orderStatusI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->orderStatusI18nsScheduledForDeletion = clone $orderStatusI18nsToDelete; foreach ($orderStatusI18nsToDelete as $orderStatusI18nRemoved) { $orderStatusI18nRemoved->setOrderStatus(null); @@ -1567,13 +1687,13 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Returns the number of related OrderStatusI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related OrderStatusI18n objects. * @throws PropelException */ - public function countOrderStatusI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countOrderStatusI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collOrderStatusI18nsPartial && !$this->isNew(); if (null === $this->collOrderStatusI18ns || null !== $criteria || $partial) { @@ -1581,10 +1701,11 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getOrderStatusI18ns()); } - $query = OrderStatusI18nQuery::create(null, $criteria); + + $query = ChildOrderStatusI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1598,13 +1719,13 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } /** - * Method called to associate a OrderStatusI18n object to this object - * through the OrderStatusI18n foreign key attribute. + * Method called to associate a ChildOrderStatusI18n object to this object + * through the ChildOrderStatusI18n foreign key attribute. * - * @param OrderStatusI18n $l OrderStatusI18n - * @return OrderStatus The current object (for fluent API support) + * @param ChildOrderStatusI18n $l ChildOrderStatusI18n + * @return \Thelia\Model\OrderStatus The current object (for fluent API support) */ - public function addOrderStatusI18n(OrderStatusI18n $l) + public function addOrderStatusI18n(ChildOrderStatusI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1614,6 +1735,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $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); } @@ -1622,7 +1744,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } /** - * @param OrderStatusI18n $orderStatusI18n The orderStatusI18n object to add. + * @param OrderStatusI18n $orderStatusI18n The orderStatusI18n object to add. */ protected function doAddOrderStatusI18n($orderStatusI18n) { @@ -1631,8 +1753,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } /** - * @param OrderStatusI18n $orderStatusI18n The orderStatusI18n object to remove. - * @return OrderStatus The current object (for fluent API support) + * @param OrderStatusI18n $orderStatusI18n The orderStatusI18n object to remove. + * @return ChildOrderStatus The current object (for fluent API support) */ public function removeOrderStatusI18n($orderStatusI18n) { @@ -1659,8 +1781,6 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1672,14 +1792,13 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collOrders) { foreach ($this->collOrders as $o) { $o->clearAllReferences($deep); @@ -1690,42 +1809,30 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collOrders instanceof PropelCollection) { + if ($this->collOrders instanceof Collection) { $this->collOrders->clearIterator(); } $this->collOrders = null; - if ($this->collOrderStatusI18ns instanceof PropelCollection) { + if ($this->collOrderStatusI18ns instanceof Collection) { $this->collOrderStatusI18ns->clearIterator(); } $this->collOrderStatusI18ns = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(OrderStatusTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1733,11 +1840,11 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * 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) + * @return ChildOrderStatus The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = OrderStatusPeer::UPDATED_AT; + $this->modifiedColumns[] = OrderStatusTableMap::UPDATED_AT; return $this; } @@ -1749,9 +1856,9 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return OrderStatus The current object (for fluent API support) + * @return ChildOrderStatus The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1772,10 +1879,10 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return OrderStatusI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildOrderStatusI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collOrderStatusI18ns) { @@ -1788,10 +1895,10 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new OrderStatusI18n(); + $translation = new ChildOrderStatusI18n(); $translation->setLocale($locale); } else { - $translation = OrderStatusI18nQuery::create() + $translation = ChildOrderStatusI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -1806,14 +1913,14 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return OrderStatus The current object (for fluent API support) + * @return ChildOrderStatus The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - OrderStatusI18nQuery::create() + ChildOrderStatusI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -1833,10 +1940,10 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return OrderStatusI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildOrderStatusI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -1845,7 +1952,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -1856,8 +1963,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -1869,7 +1976,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -1880,8 +1987,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -1893,7 +2000,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -1904,8 +2011,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -1917,7 +2024,7 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -1928,8 +2035,8 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -1937,4 +2044,122 @@ abstract class BaseOrderStatus extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18n.php b/core/lib/Thelia/Model/Base/OrderStatusI18n.php new file mode 100644 index 000000000..1f98739f0 --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderStatusI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\OrderStatusI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another OrderStatusI18n instance. If + * obj is an instance of OrderStatusI18n, delegates to + * equals(OrderStatusI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return OrderStatusI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return OrderStatusI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\OrderStatusI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = OrderStatusI18nTableMap::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 \Thelia\Model\OrderStatusI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = OrderStatusI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = OrderStatusI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = OrderStatusI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = OrderStatusI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = OrderStatusI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderStatusI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderStatusI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderStatusI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderStatusI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderStatusI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderStatusI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = OrderStatusI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\OrderStatusI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(OrderStatusI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildOrderStatusI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aOrderStatus = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see OrderStatusI18n::setDeleted() + * @see OrderStatusI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildOrderStatusI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME); + } + + $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); + OrderStatusI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderStatusI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderStatusI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(OrderStatusI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(OrderStatusI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(OrderStatusI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(OrderStatusI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderStatusI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['OrderStatusI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['OrderStatusI18n'][serialize($this->getPrimaryKey())] = true; + $keys = OrderStatusI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = OrderStatusI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = OrderStatusI18nTableMap::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(OrderStatusI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(OrderStatusI18nTableMap::ID)) $criteria->add(OrderStatusI18nTableMap::ID, $this->id); + if ($this->isColumnModified(OrderStatusI18nTableMap::LOCALE)) $criteria->add(OrderStatusI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(OrderStatusI18nTableMap::TITLE)) $criteria->add(OrderStatusI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(OrderStatusI18nTableMap::DESCRIPTION)) $criteria->add(OrderStatusI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(OrderStatusI18nTableMap::CHAPO)) $criteria->add(OrderStatusI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(OrderStatusI18nTableMap::POSTSCRIPTUM)) $criteria->add(OrderStatusI18nTableMap::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(OrderStatusI18nTableMap::DATABASE_NAME); + $criteria->add(OrderStatusI18nTableMap::ID, $this->id); + $criteria->add(OrderStatusI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildOrderStatus object. + * + * @param ChildOrderStatus $v + * @return \Thelia\Model\OrderStatusI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setOrderStatus(ChildOrderStatus $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 ChildOrderStatus object, it will not be re-added. + if ($v !== null) { + $v->addOrderStatusI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildOrderStatus object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildOrderStatus The associated ChildOrderStatus object. + * @throws PropelException + */ + public function getOrderStatus(ConnectionInterface $con = null) + { + if ($this->aOrderStatus === null && ($this->id !== null)) { + $this->aOrderStatus = ChildOrderStatusQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aOrderStatus = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(OrderStatusI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18nQuery.php b/core/lib/Thelia/Model/Base/OrderStatusI18nQuery.php new file mode 100644 index 000000000..58127979f --- /dev/null +++ b/core/lib/Thelia/Model/Base/OrderStatusI18nQuery.php @@ -0,0 +1,607 @@ +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[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildOrderStatusI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = OrderStatusI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(OrderStatusI18nTableMap::DATABASE_NAME); + } + $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 ConnectionInterface $con A connection object + * + * @return ChildOrderStatusI18n A model object, or null if the key is not found + */ + 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), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderStatusI18n(); + $obj->hydrate($row); + OrderStatusI18nTableMap::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 ConnectionInterface $con A connection object + * + * @return ChildOrderStatusI18n|array|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; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * 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 ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildOrderStatusI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(OrderStatusI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(OrderStatusI18nTableMap::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 ChildOrderStatusI18nQuery 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(OrderStatusI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(OrderStatusI18nTableMap::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 + * + * + * @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 ChildOrderStatusI18nQuery 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(OrderStatusI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(OrderStatusI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderStatusI18nTableMap::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 ChildOrderStatusI18nQuery 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(OrderStatusI18nTableMap::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 ChildOrderStatusI18nQuery 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(OrderStatusI18nTableMap::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 ChildOrderStatusI18nQuery 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(OrderStatusI18nTableMap::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 ChildOrderStatusI18nQuery 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(OrderStatusI18nTableMap::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 ChildOrderStatusI18nQuery 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(OrderStatusI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\OrderStatus object + * + * @param \Thelia\Model\OrderStatus|ObjectCollection $orderStatus The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderStatusI18nQuery The current query, for fluid interface + */ + public function filterByOrderStatus($orderStatus, $comparison = null) + { + if ($orderStatus instanceof \Thelia\Model\OrderStatus) { + return $this + ->addUsingAlias(OrderStatusI18nTableMap::ID, $orderStatus->getId(), $comparison); + } elseif ($orderStatus instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(OrderStatusI18nTableMap::ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByOrderStatus() only accepts arguments of type \Thelia\Model\OrderStatus or Collection'); + } + } + + /** + * 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 ChildOrderStatusI18nQuery 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 ChildOrderStatusI18n $orderStatusI18n Object to remove from the list of results + * + * @return ChildOrderStatusI18nQuery The current query, for fluid interface + */ + public function prune($orderStatusI18n = null) + { + if ($orderStatusI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(OrderStatusI18nTableMap::ID), $orderStatusI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(OrderStatusI18nTableMap::LOCALE), $orderStatusI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the order_status_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderStatusI18nTableMap::clearInstancePool(); + OrderStatusI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderStatusI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderStatusI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderStatusI18nTableMap::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(); + + + OrderStatusI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderStatusI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // OrderStatusI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php b/core/lib/Thelia/Model/Base/OrderStatusQuery.php old mode 100755 new mode 100644 similarity index 54% rename from core/lib/Thelia/Model/om/BaseOrderStatusQuery.php rename to core/lib/Thelia/Model/Base/OrderStatusQuery.php index d8c1f3c7f..07fcdb8dc --- a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php +++ b/core/lib/Thelia/Model/Base/OrderStatusQuery.php @@ -1,92 +1,92 @@ setModelAlias($modelAlias); } @@ -107,21 +107,21 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return OrderStatus|OrderStatus[]|mixed the result, formatted by the current formatter + * @return ChildOrderStatus|array|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 + if ((null !== ($obj = OrderStatusTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(OrderStatusTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -133,46 +133,31 @@ abstract class BaseOrderStatusQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return OrderStatus A model object, or null if the key is not found - * @throws PropelException + * @return ChildOrderStatus A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `order_status` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new OrderStatus(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildOrderStatus(); $obj->hydrate($row); - OrderStatusPeer::addInstanceToPool($obj, (string) $key); + OrderStatusTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -183,19 +168,19 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return OrderStatus|OrderStatus[]|mixed the result, formatted by the current formatter + * @return ChildOrderStatus|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -204,22 +189,22 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|OrderStatus[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -227,12 +212,12 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return OrderStatusQuery The current query, for fluid interface + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(OrderStatusPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(OrderStatusTableMap::ID, $key, Criteria::EQUAL); } /** @@ -240,12 +225,12 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return OrderStatusQuery The current query, for fluid interface + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(OrderStatusPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(OrderStatusTableMap::ID, $keys, Criteria::IN); } /** @@ -255,8 +240,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -265,18 +249,18 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * 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 + * @return ChildOrderStatusQuery 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); + $this->addUsingAlias(OrderStatusTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(OrderStatusPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderStatusTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -287,7 +271,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderStatusPeer::ID, $id, $comparison); + return $this->addUsingAlias(OrderStatusTableMap::ID, $id, $comparison); } /** @@ -303,7 +287,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * 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 + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -316,7 +300,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderStatusPeer::CODE, $code, $comparison); + return $this->addUsingAlias(OrderStatusTableMap::CODE, $code, $comparison); } /** @@ -337,18 +321,18 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * 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 + * @return ChildOrderStatusQuery 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); + $this->addUsingAlias(OrderStatusTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderStatusTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -359,7 +343,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(OrderStatusTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -380,18 +364,18 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * 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 + * @return ChildOrderStatusQuery 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); + $this->addUsingAlias(OrderStatusTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(OrderStatusTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -402,30 +386,29 @@ abstract class BaseOrderStatusQuery extends ModelCriteria } } - return $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(OrderStatusTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Order object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Order|ObjectCollection $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. + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function filterByOrder($order, $comparison = null) { - if ($order instanceof Order) { + if ($order instanceof \Thelia\Model\Order) { return $this - ->addUsingAlias(OrderStatusPeer::ID, $order->getStatusId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { + ->addUsingAlias(OrderStatusTableMap::ID, $order->getStatusId(), $comparison); + } elseif ($order instanceof ObjectCollection) { return $this ->useOrderQuery() ->filterByPrimaryKeys($order->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); + throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); } } @@ -435,7 +418,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * @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 + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -464,7 +447,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria /** * Use the Order relation Order object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -480,26 +463,25 @@ abstract class BaseOrderStatusQuery extends ModelCriteria } /** - * Filter the query by a related OrderStatusI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\OrderStatusI18n|ObjectCollection $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. + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function filterByOrderStatusI18n($orderStatusI18n, $comparison = null) { - if ($orderStatusI18n instanceof OrderStatusI18n) { + if ($orderStatusI18n instanceof \Thelia\Model\OrderStatusI18n) { return $this - ->addUsingAlias(OrderStatusPeer::ID, $orderStatusI18n->getId(), $comparison); - } elseif ($orderStatusI18n instanceof PropelObjectCollection) { + ->addUsingAlias(OrderStatusTableMap::ID, $orderStatusI18n->getId(), $comparison); + } elseif ($orderStatusI18n instanceof ObjectCollection) { return $this ->useOrderStatusI18nQuery() ->filterByPrimaryKeys($orderStatusI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderStatusI18n() only accepts arguments of type OrderStatusI18n or PropelCollection'); + throw new PropelException('filterByOrderStatusI18n() only accepts arguments of type \Thelia\Model\OrderStatusI18n or Collection'); } } @@ -509,7 +491,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * @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 + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function joinOrderStatusI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -538,7 +520,7 @@ abstract class BaseOrderStatusQuery extends ModelCriteria /** * Use the OrderStatusI18n relation OrderStatusI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -556,19 +538,94 @@ abstract class BaseOrderStatusQuery extends ModelCriteria /** * Exclude object from result * - * @param OrderStatus $orderStatus Object to remove from the list of results + * @param ChildOrderStatus $orderStatus Object to remove from the list of results * - * @return OrderStatusQuery The current query, for fluid interface + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function prune($orderStatus = null) { if ($orderStatus) { - $this->addUsingAlias(OrderStatusPeer::ID, $orderStatus->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(OrderStatusTableMap::ID, $orderStatus->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the order_status table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + OrderStatusTableMap::clearInstancePool(); + OrderStatusTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildOrderStatus or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildOrderStatus object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(OrderStatusTableMap::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(); + + + OrderStatusTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + OrderStatusTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -576,31 +633,11 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return OrderStatusQuery The current query, for fluid interface + * @return ChildOrderStatusQuery 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); + return $this->addUsingAlias(OrderStatusTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -608,32 +645,53 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return OrderStatusQuery The current query, for fluid interface + * @return ChildOrderStatusQuery 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); + return $this->addUsingAlias(OrderStatusTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildOrderStatusQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(OrderStatusTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildOrderStatusQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(OrderStatusTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return OrderStatusQuery The current query, for fluid interface + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(OrderStatusPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(OrderStatusTableMap::CREATED_AT); } /** * Order by create date asc * - * @return OrderStatusQuery The current query, for fluid interface + * @return ChildOrderStatusQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(OrderStatusPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(OrderStatusTableMap::CREATED_AT); } + // i18n behavior /** @@ -643,9 +701,9 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * @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 + * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'OrderStatusI18n'; @@ -661,9 +719,9 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * @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 + * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -682,13 +740,13 @@ abstract class BaseOrderStatusQuery extends ModelCriteria * @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 + * @return ChildOrderStatusI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderStatusI18n', 'Thelia\Model\OrderStatusI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'OrderStatusI18n', '\Thelia\Model\OrderStatusI18nQuery'); } -} +} // OrderStatusQuery diff --git a/core/lib/Thelia/Model/om/BaseProduct.php b/core/lib/Thelia/Model/Base/Product.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseProduct.php rename to core/lib/Thelia/Model/Base/Product.php index a48b71c31..29769aef9 --- a/core/lib/Thelia/Model/om/BaseProduct.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -1,76 +1,84 @@ applyDefaultValues(); } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Product instance. If + * obj is an instance of Product, delegates to + * equals(Product). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Product The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Product The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [tax_rule_id] column value. * - * @return int + * @return int */ public function getTaxRuleId() { + return $this->tax_rule_id; } /** * Get the [ref] column value. * - * @return string + * @return string */ public function getRef() { + return $this->ref; } /** * Get the [price] column value. * - * @return double + * @return double */ public function getPrice() { + return $this->price; } /** * Get the [price2] column value. * - * @return double + * @return double */ public function getPrice2() { + return $this->price2; } /** * Get the [ecotax] column value. * - * @return double + * @return double */ public function getEcotax() { + return $this->ecotax; } /** * Get the [newness] column value. * - * @return int + * @return int */ public function getNewness() { + return $this->newness; } /** * Get the [promo] column value. * - * @return int + * @return int */ public function getPromo() { + return $this->promo; } /** * Get the [quantity] column value. * - * @return int + * @return int */ public function getQuantity() { + return $this->quantity; } /** * Get the [visible] column value. * - * @return int + * @return int */ public function getVisible() { + return $this->visible; } /** * Get the [weight] column value. * - * @return double + * @return double */ public function getWeight() { + return $this->weight; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -540,89 +794,50 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version] column value. * - * @return int + * @return int */ public function getVersion() { + return $this->version; } @@ -630,67 +845,48 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getVersionCreatedAt($format = NULL) { - 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; + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version_created_by] column value. * - * @return string + * @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) + * @param int $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = ProductPeer::ID; + $this->modifiedColumns[] = ProductTableMap::ID; } @@ -700,18 +896,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [tax_rule_id] column. * - * @param int $v new value - * @return Product The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setTaxRuleId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->tax_rule_id !== $v) { $this->tax_rule_id = $v; - $this->modifiedColumns[] = ProductPeer::TAX_RULE_ID; + $this->modifiedColumns[] = ProductTableMap::TAX_RULE_ID; } if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) { @@ -725,18 +921,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [ref] column. * - * @param string $v new value - * @return Product The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setRef($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->ref !== $v) { $this->ref = $v; - $this->modifiedColumns[] = ProductPeer::REF; + $this->modifiedColumns[] = ProductTableMap::REF; } @@ -746,18 +942,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [price] column. * - * @param double $v new value - * @return Product The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setPrice($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->price !== $v) { $this->price = $v; - $this->modifiedColumns[] = ProductPeer::PRICE; + $this->modifiedColumns[] = ProductTableMap::PRICE; } @@ -767,18 +963,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [price2] column. * - * @param double $v new value - * @return Product The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setPrice2($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->price2 !== $v) { $this->price2 = $v; - $this->modifiedColumns[] = ProductPeer::PRICE2; + $this->modifiedColumns[] = ProductTableMap::PRICE2; } @@ -788,18 +984,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [ecotax] column. * - * @param double $v new value - * @return Product The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setEcotax($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->ecotax !== $v) { $this->ecotax = $v; - $this->modifiedColumns[] = ProductPeer::ECOTAX; + $this->modifiedColumns[] = ProductTableMap::ECOTAX; } @@ -809,18 +1005,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [newness] column. * - * @param int $v new value - * @return Product The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setNewness($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->newness !== $v) { $this->newness = $v; - $this->modifiedColumns[] = ProductPeer::NEWNESS; + $this->modifiedColumns[] = ProductTableMap::NEWNESS; } @@ -830,18 +1026,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [promo] column. * - * @param int $v new value - * @return Product The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setPromo($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->promo !== $v) { $this->promo = $v; - $this->modifiedColumns[] = ProductPeer::PROMO; + $this->modifiedColumns[] = ProductTableMap::PROMO; } @@ -851,18 +1047,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [quantity] column. * - * @param int $v new value - * @return Product The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setQuantity($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->quantity !== $v) { $this->quantity = $v; - $this->modifiedColumns[] = ProductPeer::QUANTITY; + $this->modifiedColumns[] = ProductTableMap::QUANTITY; } @@ -872,18 +1068,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [visible] column. * - * @param int $v new value - * @return Product The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setVisible($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->visible !== $v) { $this->visible = $v; - $this->modifiedColumns[] = ProductPeer::VISIBLE; + $this->modifiedColumns[] = ProductTableMap::VISIBLE; } @@ -893,18 +1089,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [weight] column. * - * @param double $v new value - * @return Product The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setWeight($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->weight !== $v) { $this->weight = $v; - $this->modifiedColumns[] = ProductPeer::WEIGHT; + $this->modifiedColumns[] = ProductTableMap::WEIGHT; } @@ -914,18 +1110,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return Product The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = ProductPeer::POSITION; + $this->modifiedColumns[] = ProductTableMap::POSITION; } @@ -935,19 +1131,17 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ProductTableMap::CREATED_AT; } } // if either are not null @@ -958,19 +1152,17 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ProductTableMap::UPDATED_AT; } } // if either are not null @@ -981,18 +1173,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [version] column. * - * @param int $v new value - * @return Product The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setVersion($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->version !== $v) { $this->version = $v; - $this->modifiedColumns[] = ProductPeer::VERSION; + $this->modifiedColumns[] = ProductTableMap::VERSION; } @@ -1002,19 +1194,17 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setVersionCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = ProductTableMap::VERSION_CREATED_AT; } } // if either are not null @@ -1025,18 +1215,18 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [version_created_by] column. * - * @param string $v new value - * @return Product The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Product The current object (for fluent API support) */ public function setVersionCreatedBy($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->version_created_by !== $v) { $this->version_created_by = $v; - $this->modifiedColumns[] = ProductPeer::VERSION_CREATED_BY; + $this->modifiedColumns[] = ProductTableMap::VERSION_CREATED_BY; } @@ -1073,7 +1263,7 @@ abstract class BaseProduct extends BaseObject implements Persistent return false; } - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -1085,33 +1275,80 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductTableMap::translateFieldName('TaxRuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_rule_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; + $this->price = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductTableMap::translateFieldName('Price2', TableMap::TYPE_PHPNAME, $indexType)]; + $this->price2 = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductTableMap::translateFieldName('Ecotax', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ecotax = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)]; + $this->newness = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->promo = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; + $this->quantity = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; + $this->weight = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : ProductTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : ProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : ProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : ProductTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : ProductTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : ProductTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -1119,11 +1356,11 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 17; // 17 = ProductPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 17; // 17 = ProductTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Product object", $e); + throw new PropelException("Error populating \Thelia\Model\Product object", 0, $e); } } @@ -1142,7 +1379,6 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) { $this->aTaxRule = null; } @@ -1153,12 +1389,12 @@ abstract class BaseProduct extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -1169,24 +1405,24 @@ abstract class BaseProduct extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ProductTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildProductQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? $this->aTaxRule = null; - $this->collProductCategorys = null; + $this->collProductCategories = null; $this->collFeatureProds = null; @@ -1198,9 +1434,9 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collDocuments = null; - $this->collAccessorysRelatedByProductId = null; + $this->collAccessoriesRelatedByProductId = null; - $this->collAccessorysRelatedByAccessory = null; + $this->collAccessoriesRelatedByAccessory = null; $this->collRewritings = null; @@ -1208,7 +1444,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->collProductVersions = null; - $this->collCategorys = null; + $this->collCategories = null; $this->collProductsRelatedByAccessory = null; $this->collProductsRelatedByProductId = null; } // if (deep) @@ -1217,26 +1453,25 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Product::setDeleted() + * @see Product::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ProductQuery::create() + $deleteQuery = ChildProductQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -1261,20 +1496,19 @@ abstract class BaseProduct extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -1284,7 +1518,7 @@ abstract class BaseProduct extends BaseObject implements Persistent // versionable behavior if ($this->isVersioningNecessary()) { $this->setVersion($this->isNew() ? 1 : $this->getLastVersionNumber($con) + 1); - if (!$this->isColumnModified(ProductPeer::VERSION_CREATED_AT)) { + if (!$this->isColumnModified(ProductTableMap::VERSION_CREATED_AT)) { $this->setVersionCreatedAt(time()); } $createVersion = true; // for postSave hook @@ -1292,16 +1526,16 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(ProductPeer::CREATED_AT)) { + if (!$this->isColumnModified(ProductTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(ProductPeer::UPDATED_AT)) { + if (!$this->isColumnModified(ProductTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ProductPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(ProductTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -1317,7 +1551,7 @@ abstract class BaseProduct extends BaseObject implements Persistent if (isset($createVersion)) { $this->addVersion($con); } - ProductPeer::addInstanceToPool($this); + ProductTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1336,19 +1570,19 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -1370,26 +1604,27 @@ abstract class BaseProduct extends BaseObject implements Persistent $this->resetModified(); } - if ($this->categorysScheduledForDeletion !== null) { - if (!$this->categorysScheduledForDeletion->isEmpty()) { + if ($this->categoriesScheduledForDeletion !== null) { + if (!$this->categoriesScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->categorysScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + $pk = $this->getPrimaryKey(); + foreach ($this->categoriesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($pk, $remotePk); } + ProductCategoryQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); - $this->categorysScheduledForDeletion = null; + $this->categoriesScheduledForDeletion = null; } - foreach ($this->getCategorys() as $category) { + foreach ($this->getCategories() as $category) { if ($category->isModified()) { $category->save($con); } } - } elseif ($this->collCategorys) { - foreach ($this->collCategorys as $category) { + } elseif ($this->collCategories) { + foreach ($this->collCategories as $category) { if ($category->isModified()) { $category->save($con); } @@ -1399,10 +1634,11 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->productsRelatedByAccessoryScheduledForDeletion !== null) { if (!$this->productsRelatedByAccessoryScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->productsRelatedByAccessoryScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($pk, $remotePk); } + AccessoryRelatedByProductIdQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -1425,10 +1661,11 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->productsRelatedByProductIdScheduledForDeletion !== null) { if (!$this->productsRelatedByProductIdScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->productsRelatedByProductIdScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($pk, $remotePk); } + AccessoryRelatedByAccessoryQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -1448,17 +1685,17 @@ abstract class BaseProduct extends BaseObject implements Persistent } } - if ($this->productCategorysScheduledForDeletion !== null) { - if (!$this->productCategorysScheduledForDeletion->isEmpty()) { - ProductCategoryQuery::create() - ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false)) + if ($this->productCategoriesScheduledForDeletion !== null) { + if (!$this->productCategoriesScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProductCategoryQuery::create() + ->filterByPrimaryKeys($this->productCategoriesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->productCategorysScheduledForDeletion = null; + $this->productCategoriesScheduledForDeletion = null; } } - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { + if ($this->collProductCategories !== null) { + foreach ($this->collProductCategories as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1467,15 +1704,15 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->featureProdsScheduledForDeletion !== null) { if (!$this->featureProdsScheduledForDeletion->isEmpty()) { - FeatureProdQuery::create() + \Thelia\Model\FeatureProdQuery::create() ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->featureProdsScheduledForDeletion = null; } } - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { + if ($this->collFeatureProds !== null) { + foreach ($this->collFeatureProds as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1484,15 +1721,15 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->stocksScheduledForDeletion !== null) { if (!$this->stocksScheduledForDeletion->isEmpty()) { - StockQuery::create() + \Thelia\Model\StockQuery::create() ->filterByPrimaryKeys($this->stocksScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->stocksScheduledForDeletion = null; } } - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { + if ($this->collStocks !== null) { + foreach ($this->collStocks as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1501,16 +1738,15 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->contentAssocsScheduledForDeletion !== null) { if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { - // need to save related object because we set the relation to null - $contentAssoc->save($con); - } + \Thelia\Model\ContentAssocQuery::create() + ->filterByPrimaryKeys($this->contentAssocsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->contentAssocsScheduledForDeletion = null; } } - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { + if ($this->collContentAssocs !== null) { + foreach ($this->collContentAssocs as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1519,16 +1755,15 @@ abstract class BaseProduct extends BaseObject implements Persistent 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); - } + \Thelia\Model\ImageQuery::create() + ->filterByPrimaryKeys($this->imagesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->imagesScheduledForDeletion = null; } } - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { + if ($this->collImages !== null) { + foreach ($this->collImages as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1537,50 +1772,49 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->documentsScheduledForDeletion !== null) { if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } + \Thelia\Model\DocumentQuery::create() + ->filterByPrimaryKeys($this->documentsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->documentsScheduledForDeletion = null; } } - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { + 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)) + if ($this->accessoriesRelatedByProductIdScheduledForDeletion !== null) { + if (!$this->accessoriesRelatedByProductIdScheduledForDeletion->isEmpty()) { + \Thelia\Model\AccessoryQuery::create() + ->filterByPrimaryKeys($this->accessoriesRelatedByProductIdScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->accessorysRelatedByProductIdScheduledForDeletion = null; + $this->accessoriesRelatedByProductIdScheduledForDeletion = null; } } - if ($this->collAccessorysRelatedByProductId !== null) { - foreach ($this->collAccessorysRelatedByProductId as $referrerFK) { + if ($this->collAccessoriesRelatedByProductId !== null) { + foreach ($this->collAccessoriesRelatedByProductId 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)) + if ($this->accessoriesRelatedByAccessoryScheduledForDeletion !== null) { + if (!$this->accessoriesRelatedByAccessoryScheduledForDeletion->isEmpty()) { + \Thelia\Model\AccessoryQuery::create() + ->filterByPrimaryKeys($this->accessoriesRelatedByAccessoryScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->accessorysRelatedByAccessoryScheduledForDeletion = null; + $this->accessoriesRelatedByAccessoryScheduledForDeletion = null; } } - if ($this->collAccessorysRelatedByAccessory !== null) { - foreach ($this->collAccessorysRelatedByAccessory as $referrerFK) { + if ($this->collAccessoriesRelatedByAccessory !== null) { + foreach ($this->collAccessoriesRelatedByAccessory as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1589,16 +1823,15 @@ abstract class BaseProduct extends BaseObject implements Persistent 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); - } + \Thelia\Model\RewritingQuery::create() + ->filterByPrimaryKeys($this->rewritingsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); $this->rewritingsScheduledForDeletion = null; } } - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { + if ($this->collRewritings !== null) { + foreach ($this->collRewritings as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1607,15 +1840,15 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->productI18nsScheduledForDeletion !== null) { if (!$this->productI18nsScheduledForDeletion->isEmpty()) { - ProductI18nQuery::create() + \Thelia\Model\ProductI18nQuery::create() ->filterByPrimaryKeys($this->productI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->productI18nsScheduledForDeletion = null; } } - if ($this->collProductI18ns !== null) { - foreach ($this->collProductI18ns as $referrerFK) { + if ($this->collProductI18ns !== null) { + foreach ($this->collProductI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1624,15 +1857,15 @@ abstract class BaseProduct extends BaseObject implements Persistent if ($this->productVersionsScheduledForDeletion !== null) { if (!$this->productVersionsScheduledForDeletion->isEmpty()) { - ProductVersionQuery::create() + \Thelia\Model\ProductVersionQuery::create() ->filterByPrimaryKeys($this->productVersionsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->productVersionsScheduledForDeletion = null; } } - if ($this->collProductVersions !== null) { - foreach ($this->collProductVersions as $referrerFK) { + if ($this->collProductVersions !== null) { + foreach ($this->collProductVersions as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1649,76 +1882,76 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = ProductPeer::ID; + $this->modifiedColumns[] = ProductTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductPeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ProductPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(ProductTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ProductPeer::TAX_RULE_ID)) { - $modifiedColumns[':p' . $index++] = '`tax_rule_id`'; + if ($this->isColumnModified(ProductTableMap::TAX_RULE_ID)) { + $modifiedColumns[':p' . $index++] = 'TAX_RULE_ID'; } - if ($this->isColumnModified(ProductPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; + if ($this->isColumnModified(ProductTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; } - if ($this->isColumnModified(ProductPeer::PRICE)) { - $modifiedColumns[':p' . $index++] = '`price`'; + if ($this->isColumnModified(ProductTableMap::PRICE)) { + $modifiedColumns[':p' . $index++] = 'PRICE'; } - if ($this->isColumnModified(ProductPeer::PRICE2)) { - $modifiedColumns[':p' . $index++] = '`price2`'; + if ($this->isColumnModified(ProductTableMap::PRICE2)) { + $modifiedColumns[':p' . $index++] = 'PRICE2'; } - if ($this->isColumnModified(ProductPeer::ECOTAX)) { - $modifiedColumns[':p' . $index++] = '`ecotax`'; + if ($this->isColumnModified(ProductTableMap::ECOTAX)) { + $modifiedColumns[':p' . $index++] = 'ECOTAX'; } - if ($this->isColumnModified(ProductPeer::NEWNESS)) { - $modifiedColumns[':p' . $index++] = '`newness`'; + if ($this->isColumnModified(ProductTableMap::NEWNESS)) { + $modifiedColumns[':p' . $index++] = 'NEWNESS'; } - if ($this->isColumnModified(ProductPeer::PROMO)) { - $modifiedColumns[':p' . $index++] = '`promo`'; + if ($this->isColumnModified(ProductTableMap::PROMO)) { + $modifiedColumns[':p' . $index++] = 'PROMO'; } - if ($this->isColumnModified(ProductPeer::QUANTITY)) { - $modifiedColumns[':p' . $index++] = '`quantity`'; + if ($this->isColumnModified(ProductTableMap::QUANTITY)) { + $modifiedColumns[':p' . $index++] = 'QUANTITY'; } - if ($this->isColumnModified(ProductPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; + if ($this->isColumnModified(ProductTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; } - if ($this->isColumnModified(ProductPeer::WEIGHT)) { - $modifiedColumns[':p' . $index++] = '`weight`'; + if ($this->isColumnModified(ProductTableMap::WEIGHT)) { + $modifiedColumns[':p' . $index++] = 'WEIGHT'; } - if ($this->isColumnModified(ProductPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(ProductTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(ProductPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(ProductTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(ProductPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(ProductTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } - if ($this->isColumnModified(ProductPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`version`'; + if ($this->isColumnModified(ProductTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; } - if ($this->isColumnModified(ProductPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`version_created_at`'; + if ($this->isColumnModified(ProductTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; } - if ($this->isColumnModified(ProductPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`version_created_by`'; + if ($this->isColumnModified(ProductTableMap::VERSION_CREATED_BY)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY'; } $sql = sprintf( - 'INSERT INTO `product` (%s) VALUES (%s)', + 'INSERT INTO product (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1727,55 +1960,55 @@ abstract class BaseProduct extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`tax_rule_id`': + case 'TAX_RULE_ID': $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT); break; - case '`ref`': + case 'REF': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`price`': + case 'PRICE': $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); break; - case '`price2`': + case 'PRICE2': $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR); break; - case '`ecotax`': + case 'ECOTAX': $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR); break; - case '`newness`': + case 'NEWNESS': $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT); break; - case '`promo`': + case 'PROMO': $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT); break; - case '`quantity`': + case 'QUANTITY': $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_INT); break; - case '`visible`': + case 'VISIBLE': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`weight`': + case 'WEIGHT': $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version`': + 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); + case 'VERSION_CREATED_AT': + $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version_created_by`': + case 'VERSION_CREATED_BY': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1783,13 +2016,13 @@ abstract class BaseProduct extends BaseObject implements Persistent $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -1799,204 +2032,32 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = ProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -2006,7 +2067,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -2075,22 +2136,22 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = ProductTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getTaxRuleId(), @@ -2110,12 +2171,18 @@ abstract class BaseProduct extends BaseObject implements Persistent $keys[15] => $this->getVersionCreatedAt(), $keys[16] => $this->getVersionCreatedBy(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + 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->collProductCategories) { + $result['ProductCategories'] = $this->collProductCategories->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collFeatureProds) { $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -2132,11 +2199,11 @@ abstract class BaseProduct extends BaseObject implements Persistent 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->collAccessoriesRelatedByProductId) { + $result['AccessoriesRelatedByProductId'] = $this->collAccessoriesRelatedByProductId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collAccessorysRelatedByAccessory) { - $result['AccessorysRelatedByAccessory'] = $this->collAccessorysRelatedByAccessory->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collAccessoriesRelatedByAccessory) { + $result['AccessoriesRelatedByAccessory'] = $this->collAccessoriesRelatedByAccessory->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collRewritings) { $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -2155,27 +2222,27 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = ProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ProductTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -2244,17 +2311,17 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = ProductPeer::getFieldNames($keyType); + $keys = ProductTableMap::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]]); @@ -2282,25 +2349,25 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(ProductPeer::DATABASE_NAME); + $criteria = new Criteria(ProductTableMap::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); + if ($this->isColumnModified(ProductTableMap::ID)) $criteria->add(ProductTableMap::ID, $this->id); + if ($this->isColumnModified(ProductTableMap::TAX_RULE_ID)) $criteria->add(ProductTableMap::TAX_RULE_ID, $this->tax_rule_id); + if ($this->isColumnModified(ProductTableMap::REF)) $criteria->add(ProductTableMap::REF, $this->ref); + if ($this->isColumnModified(ProductTableMap::PRICE)) $criteria->add(ProductTableMap::PRICE, $this->price); + if ($this->isColumnModified(ProductTableMap::PRICE2)) $criteria->add(ProductTableMap::PRICE2, $this->price2); + if ($this->isColumnModified(ProductTableMap::ECOTAX)) $criteria->add(ProductTableMap::ECOTAX, $this->ecotax); + if ($this->isColumnModified(ProductTableMap::NEWNESS)) $criteria->add(ProductTableMap::NEWNESS, $this->newness); + if ($this->isColumnModified(ProductTableMap::PROMO)) $criteria->add(ProductTableMap::PROMO, $this->promo); + if ($this->isColumnModified(ProductTableMap::QUANTITY)) $criteria->add(ProductTableMap::QUANTITY, $this->quantity); + if ($this->isColumnModified(ProductTableMap::VISIBLE)) $criteria->add(ProductTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(ProductTableMap::WEIGHT)) $criteria->add(ProductTableMap::WEIGHT, $this->weight); + if ($this->isColumnModified(ProductTableMap::POSITION)) $criteria->add(ProductTableMap::POSITION, $this->position); + if ($this->isColumnModified(ProductTableMap::CREATED_AT)) $criteria->add(ProductTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProductTableMap::UPDATED_AT)) $criteria->add(ProductTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(ProductTableMap::VERSION)) $criteria->add(ProductTableMap::VERSION, $this->version); + if ($this->isColumnModified(ProductTableMap::VERSION_CREATED_AT)) $criteria->add(ProductTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(ProductTableMap::VERSION_CREATED_BY)) $criteria->add(ProductTableMap::VERSION_CREATED_BY, $this->version_created_by); return $criteria; } @@ -2315,15 +2382,15 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(ProductPeer::DATABASE_NAME); - $criteria->add(ProductPeer::ID, $this->id); + $criteria = new Criteria(ProductTableMap::DATABASE_NAME); + $criteria->add(ProductTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -2333,7 +2400,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -2357,9 +2424,9 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -2381,14 +2448,12 @@ abstract class BaseProduct extends BaseObject implements Persistent $copyObj->setVersionCreatedAt($this->getVersionCreatedAt()); $copyObj->setVersionCreatedBy($this->getVersionCreatedBy()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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) { + foreach ($this->getProductCategories() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addProductCategory($relObj->copy($deepCopy)); } @@ -2424,13 +2489,13 @@ abstract class BaseProduct extends BaseObject implements Persistent } } - foreach ($this->getAccessorysRelatedByProductId() as $relObj) { + foreach ($this->getAccessoriesRelatedByProductId() 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) { + foreach ($this->getAccessoriesRelatedByAccessory() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addAccessoryRelatedByAccessory($relObj->copy($deepCopy)); } @@ -2454,8 +2519,6 @@ abstract class BaseProduct extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -2472,8 +2535,8 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Product Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -2487,31 +2550,13 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildTaxRule object. * - * 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) + * @param ChildTaxRule $v + * @return \Thelia\Model\Product The current object (for fluent API support) * @throws PropelException */ - public function setTaxRule(TaxRule $v = null) + public function setTaxRule(ChildTaxRule $v = null) { if ($v === null) { $this->setTaxRuleId(NULL); @@ -2522,7 +2567,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $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 this object has already been added to the ChildTaxRule object, it will not be re-added. if ($v !== null) { $v->addProduct($this); } @@ -2533,17 +2578,16 @@ abstract class BaseProduct extends BaseObject implements Persistent /** - * Get the associated TaxRule object + * Get the associated ChildTaxRule object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return TaxRule The associated TaxRule object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildTaxRule The associated ChildTaxRule object. * @throws PropelException */ - public function getTaxRule(PropelPDO $con = null, $doQuery = true) + public function getTaxRule(ConnectionInterface $con = null) { - if ($this->aTaxRule === null && ($this->tax_rule_id !== null) && $doQuery) { - $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_id, $con); + if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) { + $this->aTaxRule = ChildTaxRuleQuery::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 @@ -2562,150 +2606,147 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('ProductCategory' == $relationName) { - $this->initProductCategorys(); + return $this->initProductCategories(); } if ('FeatureProd' == $relationName) { - $this->initFeatureProds(); + return $this->initFeatureProds(); } if ('Stock' == $relationName) { - $this->initStocks(); + return $this->initStocks(); } if ('ContentAssoc' == $relationName) { - $this->initContentAssocs(); + return $this->initContentAssocs(); } if ('Image' == $relationName) { - $this->initImages(); + return $this->initImages(); } if ('Document' == $relationName) { - $this->initDocuments(); + return $this->initDocuments(); } if ('AccessoryRelatedByProductId' == $relationName) { - $this->initAccessorysRelatedByProductId(); + return $this->initAccessoriesRelatedByProductId(); } if ('AccessoryRelatedByAccessory' == $relationName) { - $this->initAccessorysRelatedByAccessory(); + return $this->initAccessoriesRelatedByAccessory(); } if ('Rewriting' == $relationName) { - $this->initRewritings(); + return $this->initRewritings(); } if ('ProductI18n' == $relationName) { - $this->initProductI18ns(); + return $this->initProductI18ns(); } if ('ProductVersion' == $relationName) { - $this->initProductVersions(); + return $this->initProductVersions(); } } /** - * Clears out the collProductCategorys collection + * Clears out the collProductCategories collection * * This 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 + * @see addProductCategories() */ - public function resetPartialProductCategorys($v = true) + public function clearProductCategories() { - $this->collProductCategorysPartial = $v; + $this->collProductCategories = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collProductCategorys collection. + * Reset is the collProductCategories collection loaded partially. + */ + public function resetPartialProductCategories($v = true) + { + $this->collProductCategoriesPartial = $v; + } + + /** + * Initializes the collProductCategories collection. * - * By default this just sets the collProductCategorys collection to an empty array (like clearcollProductCategorys()); + * By default this just sets the collProductCategories collection to an empty array (like clearcollProductCategories()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initProductCategories($overrideExisting = true) { - if (null !== $this->collProductCategorys && !$overrideExisting) { + if (null !== $this->collProductCategories && !$overrideExisting) { return; } - $this->collProductCategorys = new PropelObjectCollection(); - $this->collProductCategorys->setModel('ProductCategory'); + $this->collProductCategories = new ObjectCollection(); + $this->collProductCategories->setModel('\Thelia\Model\ProductCategory'); } /** - * Gets an array of ProductCategory objects which contain a foreign key that references this object. + * Gets an array of ChildProductCategory objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProductCategory[] List of ChildProductCategory objects * @throws PropelException */ - public function getProductCategorys($criteria = null, PropelPDO $con = null) + public function getProductCategories($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { + $partial = $this->collProductCategoriesPartial && !$this->isNew(); + if (null === $this->collProductCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductCategories) { // return empty collection - $this->initProductCategorys(); + $this->initProductCategories(); } else { - $collProductCategorys = ProductCategoryQuery::create(null, $criteria) + $collProductCategories = ChildProductCategoryQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) { - $this->initProductCategorys(false); + if (false !== $this->collProductCategoriesPartial && count($collProductCategories)) { + $this->initProductCategories(false); - foreach($collProductCategorys as $obj) { - if (false == $this->collProductCategorys->contains($obj)) { - $this->collProductCategorys->append($obj); + foreach ($collProductCategories as $obj) { + if (false == $this->collProductCategories->contains($obj)) { + $this->collProductCategories->append($obj); + } } - } - $this->collProductCategorysPartial = true; + $this->collProductCategoriesPartial = true; } - $collProductCategorys->getInternalIterator()->rewind(); - return $collProductCategorys; + $collProductCategories->getInternalIterator()->rewind(); + + return $collProductCategories; } - if($partial && $this->collProductCategorys) { - foreach($this->collProductCategorys as $obj) { - if($obj->isNew()) { - $collProductCategorys[] = $obj; + if ($partial && $this->collProductCategories) { + foreach ($this->collProductCategories as $obj) { + if ($obj->isNew()) { + $collProductCategories[] = $obj; } } } - $this->collProductCategorys = $collProductCategorys; - $this->collProductCategorysPartial = false; + $this->collProductCategories = $collProductCategories; + $this->collProductCategoriesPartial = false; } } - return $this->collProductCategorys; + return $this->collProductCategories; } /** @@ -2714,27 +2755,31 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $productCategories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) + public function setProductCategories(Collection $productCategories, ConnectionInterface $con = null) { - $productCategorysToDelete = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); + $productCategoriesToDelete = $this->getProductCategories(new Criteria(), $con)->diff($productCategories); - $this->productCategorysScheduledForDeletion = unserialize(serialize($productCategorysToDelete)); - foreach ($productCategorysToDelete as $productCategoryRemoved) { + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->productCategoriesScheduledForDeletion = clone $productCategoriesToDelete; + + foreach ($productCategoriesToDelete as $productCategoryRemoved) { $productCategoryRemoved->setProduct(null); } - $this->collProductCategorys = null; - foreach ($productCategorys as $productCategory) { + $this->collProductCategories = null; + foreach ($productCategories as $productCategory) { $this->addProductCategory($productCategory); } - $this->collProductCategorys = $productCategorys; - $this->collProductCategorysPartial = false; + $this->collProductCategories = $productCategories; + $this->collProductCategoriesPartial = false; return $this; } @@ -2742,24 +2787,25 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related ProductCategory objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ProductCategory objects. * @throws PropelException */ - public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countProductCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { + $partial = $this->collProductCategoriesPartial && !$this->isNew(); + if (null === $this->collProductCategories || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProductCategories) { return 0; } - if($partial && !$criteria) { - return count($this->getProductCategorys()); + if ($partial && !$criteria) { + return count($this->getProductCategories()); } - $query = ProductCategoryQuery::create(null, $criteria); + + $query = ChildProductCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2769,23 +2815,24 @@ abstract class BaseProduct extends BaseObject implements Persistent ->count($con); } - return count($this->collProductCategorys); + return count($this->collProductCategories); } /** - * Method called to associate a ProductCategory object to this object - * through the ProductCategory foreign key attribute. + * Method called to associate a ChildProductCategory object to this object + * through the ChildProductCategory foreign key attribute. * - * @param ProductCategory $l ProductCategory - * @return Product The current object (for fluent API support) + * @param ChildProductCategory $l ChildProductCategory + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addProductCategory(ProductCategory $l) + public function addProductCategory(ChildProductCategory $l) { - if ($this->collProductCategorys === null) { - $this->initProductCategorys(); - $this->collProductCategorysPartial = true; + if ($this->collProductCategories === null) { + $this->initProductCategories(); + $this->collProductCategoriesPartial = true; } - if (!in_array($l, $this->collProductCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collProductCategories->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddProductCategory($l); } @@ -2793,27 +2840,27 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param ProductCategory $productCategory The productCategory object to add. + * @param ProductCategory $productCategory The productCategory object to add. */ protected function doAddProductCategory($productCategory) { - $this->collProductCategorys[]= $productCategory; + $this->collProductCategories[]= $productCategory; $productCategory->setProduct($this); } /** - * @param ProductCategory $productCategory The productCategory object to remove. - * @return Product The current object (for fluent API support) + * @param ProductCategory $productCategory The productCategory object to remove. + * @return ChildProduct 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(); + if ($this->getProductCategories()->contains($productCategory)) { + $this->collProductCategories->remove($this->collProductCategories->search($productCategory)); + if (null === $this->productCategoriesScheduledForDeletion) { + $this->productCategoriesScheduledForDeletion = clone $this->collProductCategories; + $this->productCategoriesScheduledForDeletion->clear(); } - $this->productCategorysScheduledForDeletion[]= clone $productCategory; + $this->productCategoriesScheduledForDeletion[]= clone $productCategory; $productCategory->setProduct(null); } @@ -2826,23 +2873,23 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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. + * been saved, it will retrieve related ProductCategories from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProductCategory[] List of ChildProductCategory objects */ - public function getProductCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getProductCategoriesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ProductCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildProductCategoryQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); - return $this->getProductCategorys($query, $con); + return $this->getProductCategories($query, $con); } /** @@ -2851,21 +2898,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addFeatureProds() */ public function clearFeatureProds() { - $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized - $this->collFeatureProdsPartial = null; - - return $this; + $this->collFeatureProds = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collFeatureProds collection loaded partially - * - * @return void + * Reset is the collFeatureProds collection loaded partially. */ public function resetPartialFeatureProds($v = true) { @@ -2879,7 +2921,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -2889,25 +2931,25 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null !== $this->collFeatureProds && !$overrideExisting) { return; } - $this->collFeatureProds = new PropelObjectCollection(); - $this->collFeatureProds->setModel('FeatureProd'); + $this->collFeatureProds = new ObjectCollection(); + $this->collFeatureProds->setModel('\Thelia\Model\FeatureProd'); } /** - * Gets an array of FeatureProd objects which contain a foreign key that references this object. + * Gets an array of ChildFeatureProd objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects * @throws PropelException */ - public function getFeatureProds($criteria = null, PropelPDO $con = null) + public function getFeatureProds($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureProdsPartial && !$this->isNew(); if (null === $this->collFeatureProds || null !== $criteria || $partial) { @@ -2915,29 +2957,31 @@ abstract class BaseProduct extends BaseObject implements Persistent // return empty collection $this->initFeatureProds(); } else { - $collFeatureProds = FeatureProdQuery::create(null, $criteria) + $collFeatureProds = ChildFeatureProdQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { - $this->initFeatureProds(false); + $this->initFeatureProds(false); - foreach($collFeatureProds as $obj) { - if (false == $this->collFeatureProds->contains($obj)) { - $this->collFeatureProds->append($obj); + foreach ($collFeatureProds as $obj) { + if (false == $this->collFeatureProds->contains($obj)) { + $this->collFeatureProds->append($obj); + } } - } - $this->collFeatureProdsPartial = true; + $this->collFeatureProdsPartial = true; } $collFeatureProds->getInternalIterator()->rewind(); + return $collFeatureProds; } - if($partial && $this->collFeatureProds) { - foreach($this->collFeatureProds as $obj) { - if($obj->isNew()) { + if ($partial && $this->collFeatureProds) { + foreach ($this->collFeatureProds as $obj) { + if ($obj->isNew()) { $collFeatureProds[] = $obj; } } @@ -2957,15 +3001,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $featureProds A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) + public function setFeatureProds(Collection $featureProds, ConnectionInterface $con = null) { $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete)); + + $this->featureProdsScheduledForDeletion = $featureProdsToDelete; foreach ($featureProdsToDelete as $featureProdRemoved) { $featureProdRemoved->setProduct(null); @@ -2985,13 +3030,13 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related FeatureProd objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related FeatureProd objects. * @throws PropelException */ - public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countFeatureProds(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureProdsPartial && !$this->isNew(); if (null === $this->collFeatureProds || null !== $criteria || $partial) { @@ -2999,10 +3044,11 @@ abstract class BaseProduct extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getFeatureProds()); } - $query = FeatureProdQuery::create(null, $criteria); + + $query = ChildFeatureProdQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3016,18 +3062,19 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Method called to associate a FeatureProd object to this object - * through the FeatureProd foreign key attribute. + * Method called to associate a ChildFeatureProd object to this object + * through the ChildFeatureProd foreign key attribute. * - * @param FeatureProd $l FeatureProd - * @return Product The current object (for fluent API support) + * @param ChildFeatureProd $l ChildFeatureProd + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addFeatureProd(FeatureProd $l) + public function addFeatureProd(ChildFeatureProd $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); } @@ -3036,7 +3083,7 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param FeatureProd $featureProd The featureProd object to add. + * @param FeatureProd $featureProd The featureProd object to add. */ protected function doAddFeatureProd($featureProd) { @@ -3045,8 +3092,8 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param FeatureProd $featureProd The featureProd object to remove. - * @return Product The current object (for fluent API support) + * @param FeatureProd $featureProd The featureProd object to remove. + * @return ChildProduct The current object (for fluent API support) */ public function removeFeatureProd($featureProd) { @@ -3075,15 +3122,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects */ - public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureProdsJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Feature', $join_behavior); + $query = ChildFeatureProdQuery::create(null, $criteria); + $query->joinWith('Feature', $joinBehavior); return $this->getFeatureProds($query, $con); } @@ -3100,15 +3147,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildFeatureProd[] List of ChildFeatureProd objects */ - public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('FeatureAv', $join_behavior); + $query = ChildFeatureProdQuery::create(null, $criteria); + $query->joinWith('FeatureAv', $joinBehavior); return $this->getFeatureProds($query, $con); } @@ -3119,21 +3166,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addStocks() */ public function clearStocks() { - $this->collStocks = null; // important to set this to null since that means it is uninitialized - $this->collStocksPartial = null; - - return $this; + $this->collStocks = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collStocks collection loaded partially - * - * @return void + * Reset is the collStocks collection loaded partially. */ public function resetPartialStocks($v = true) { @@ -3147,7 +3189,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3157,25 +3199,25 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null !== $this->collStocks && !$overrideExisting) { return; } - $this->collStocks = new PropelObjectCollection(); - $this->collStocks->setModel('Stock'); + $this->collStocks = new ObjectCollection(); + $this->collStocks->setModel('\Thelia\Model\Stock'); } /** - * Gets an array of Stock objects which contain a foreign key that references this object. + * Gets an array of ChildStock objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildStock[] List of ChildStock objects * @throws PropelException */ - public function getStocks($criteria = null, PropelPDO $con = null) + public function getStocks($criteria = null, ConnectionInterface $con = null) { $partial = $this->collStocksPartial && !$this->isNew(); if (null === $this->collStocks || null !== $criteria || $partial) { @@ -3183,29 +3225,31 @@ abstract class BaseProduct extends BaseObject implements Persistent // return empty collection $this->initStocks(); } else { - $collStocks = StockQuery::create(null, $criteria) + $collStocks = ChildStockQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collStocksPartial && count($collStocks)) { - $this->initStocks(false); + $this->initStocks(false); - foreach($collStocks as $obj) { - if (false == $this->collStocks->contains($obj)) { - $this->collStocks->append($obj); + foreach ($collStocks as $obj) { + if (false == $this->collStocks->contains($obj)) { + $this->collStocks->append($obj); + } } - } - $this->collStocksPartial = true; + $this->collStocksPartial = true; } $collStocks->getInternalIterator()->rewind(); + return $collStocks; } - if($partial && $this->collStocks) { - foreach($this->collStocks as $obj) { - if($obj->isNew()) { + if ($partial && $this->collStocks) { + foreach ($this->collStocks as $obj) { + if ($obj->isNew()) { $collStocks[] = $obj; } } @@ -3225,15 +3269,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $stocks A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setStocks(PropelCollection $stocks, PropelPDO $con = null) + public function setStocks(Collection $stocks, ConnectionInterface $con = null) { $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks); - $this->stocksScheduledForDeletion = unserialize(serialize($stocksToDelete)); + + $this->stocksScheduledForDeletion = $stocksToDelete; foreach ($stocksToDelete as $stockRemoved) { $stockRemoved->setProduct(null); @@ -3253,13 +3298,13 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related Stock objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Stock objects. * @throws PropelException */ - public function countStocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countStocks(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collStocksPartial && !$this->isNew(); if (null === $this->collStocks || null !== $criteria || $partial) { @@ -3267,10 +3312,11 @@ abstract class BaseProduct extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getStocks()); } - $query = StockQuery::create(null, $criteria); + + $query = ChildStockQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3284,18 +3330,19 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Method called to associate a Stock object to this object - * through the Stock foreign key attribute. + * Method called to associate a ChildStock object to this object + * through the ChildStock foreign key attribute. * - * @param Stock $l Stock - * @return Product The current object (for fluent API support) + * @param ChildStock $l ChildStock + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addStock(Stock $l) + public function addStock(ChildStock $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); } @@ -3304,7 +3351,7 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param Stock $stock The stock object to add. + * @param Stock $stock The stock object to add. */ protected function doAddStock($stock) { @@ -3313,8 +3360,8 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param Stock $stock The stock object to remove. - * @return Product The current object (for fluent API support) + * @param Stock $stock The stock object to remove. + * @return ChildProduct The current object (for fluent API support) */ public function removeStock($stock) { @@ -3343,15 +3390,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildStock[] List of ChildStock objects */ - public function getStocksJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getStocksJoinCombination($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = StockQuery::create(null, $criteria); - $query->joinWith('Combination', $join_behavior); + $query = ChildStockQuery::create(null, $criteria); + $query->joinWith('Combination', $joinBehavior); return $this->getStocks($query, $con); } @@ -3362,21 +3409,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addContentAssocs() */ public function clearContentAssocs() { - $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized - $this->collContentAssocsPartial = null; - - return $this; + $this->collContentAssocs = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collContentAssocs collection loaded partially - * - * @return void + * Reset is the collContentAssocs collection loaded partially. */ public function resetPartialContentAssocs($v = true) { @@ -3390,7 +3432,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3400,25 +3442,25 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null !== $this->collContentAssocs && !$overrideExisting) { return; } - $this->collContentAssocs = new PropelObjectCollection(); - $this->collContentAssocs->setModel('ContentAssoc'); + $this->collContentAssocs = new ObjectCollection(); + $this->collContentAssocs->setModel('\Thelia\Model\ContentAssoc'); } /** - * Gets an array of ContentAssoc objects which contain a foreign key that references this object. + * Gets an array of ChildContentAssoc objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects * @throws PropelException */ - public function getContentAssocs($criteria = null, PropelPDO $con = null) + public function getContentAssocs($criteria = null, ConnectionInterface $con = null) { $partial = $this->collContentAssocsPartial && !$this->isNew(); if (null === $this->collContentAssocs || null !== $criteria || $partial) { @@ -3426,29 +3468,31 @@ abstract class BaseProduct extends BaseObject implements Persistent // return empty collection $this->initContentAssocs(); } else { - $collContentAssocs = ContentAssocQuery::create(null, $criteria) + $collContentAssocs = ChildContentAssocQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); + $this->initContentAssocs(false); - foreach($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); + foreach ($collContentAssocs as $obj) { + if (false == $this->collContentAssocs->contains($obj)) { + $this->collContentAssocs->append($obj); + } } - } - $this->collContentAssocsPartial = true; + $this->collContentAssocsPartial = true; } $collContentAssocs->getInternalIterator()->rewind(); + return $collContentAssocs; } - if($partial && $this->collContentAssocs) { - foreach($this->collContentAssocs as $obj) { - if($obj->isNew()) { + if ($partial && $this->collContentAssocs) { + foreach ($this->collContentAssocs as $obj) { + if ($obj->isNew()) { $collContentAssocs[] = $obj; } } @@ -3468,15 +3512,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $contentAssocs A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) + public function setContentAssocs(Collection $contentAssocs, ConnectionInterface $con = null) { $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete)); + + $this->contentAssocsScheduledForDeletion = $contentAssocsToDelete; foreach ($contentAssocsToDelete as $contentAssocRemoved) { $contentAssocRemoved->setProduct(null); @@ -3496,13 +3541,13 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related ContentAssoc objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ContentAssoc objects. * @throws PropelException */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countContentAssocs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collContentAssocsPartial && !$this->isNew(); if (null === $this->collContentAssocs || null !== $criteria || $partial) { @@ -3510,10 +3555,11 @@ abstract class BaseProduct extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getContentAssocs()); } - $query = ContentAssocQuery::create(null, $criteria); + + $query = ChildContentAssocQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3527,18 +3573,19 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Method called to associate a ContentAssoc object to this object - * through the ContentAssoc foreign key attribute. + * Method called to associate a ChildContentAssoc object to this object + * through the ChildContentAssoc foreign key attribute. * - * @param ContentAssoc $l ContentAssoc - * @return Product The current object (for fluent API support) + * @param ChildContentAssoc $l ChildContentAssoc + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addContentAssoc(ContentAssoc $l) + public function addContentAssoc(ChildContentAssoc $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); } @@ -3547,7 +3594,7 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. + * @param ContentAssoc $contentAssoc The contentAssoc object to add. */ protected function doAddContentAssoc($contentAssoc) { @@ -3556,8 +3603,8 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return Product The current object (for fluent API support) + * @param ContentAssoc $contentAssoc The contentAssoc object to remove. + * @return ChildProduct The current object (for fluent API support) */ public function removeContentAssoc($contentAssoc) { @@ -3586,15 +3633,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects */ - public function getContentAssocsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getContentAssocsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildContentAssocQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getContentAssocs($query, $con); } @@ -3611,15 +3658,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildContentAssoc[] List of ChildContentAssoc objects */ - public function getContentAssocsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getContentAssocsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildContentAssocQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getContentAssocs($query, $con); } @@ -3630,21 +3677,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addImages() */ public function clearImages() { - $this->collImages = null; // important to set this to null since that means it is uninitialized - $this->collImagesPartial = null; - - return $this; + $this->collImages = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collImages collection loaded partially - * - * @return void + * Reset is the collImages collection loaded partially. */ public function resetPartialImages($v = true) { @@ -3658,7 +3700,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3668,25 +3710,25 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null !== $this->collImages && !$overrideExisting) { return; } - $this->collImages = new PropelObjectCollection(); - $this->collImages->setModel('Image'); + $this->collImages = new ObjectCollection(); + $this->collImages->setModel('\Thelia\Model\Image'); } /** - * Gets an array of Image objects which contain a foreign key that references this object. + * Gets an array of ChildImage objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildImage[] List of ChildImage objects * @throws PropelException */ - public function getImages($criteria = null, PropelPDO $con = null) + public function getImages($criteria = null, ConnectionInterface $con = null) { $partial = $this->collImagesPartial && !$this->isNew(); if (null === $this->collImages || null !== $criteria || $partial) { @@ -3694,29 +3736,31 @@ abstract class BaseProduct extends BaseObject implements Persistent // return empty collection $this->initImages(); } else { - $collImages = ImageQuery::create(null, $criteria) + $collImages = ChildImageQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); + $this->initImages(false); - foreach($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); + foreach ($collImages as $obj) { + if (false == $this->collImages->contains($obj)) { + $this->collImages->append($obj); + } } - } - $this->collImagesPartial = true; + $this->collImagesPartial = true; } $collImages->getInternalIterator()->rewind(); + return $collImages; } - if($partial && $this->collImages) { - foreach($this->collImages as $obj) { - if($obj->isNew()) { + if ($partial && $this->collImages) { + foreach ($this->collImages as $obj) { + if ($obj->isNew()) { $collImages[] = $obj; } } @@ -3736,15 +3780,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $images A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setImages(PropelCollection $images, PropelPDO $con = null) + public function setImages(Collection $images, ConnectionInterface $con = null) { $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); + + $this->imagesScheduledForDeletion = $imagesToDelete; foreach ($imagesToDelete as $imageRemoved) { $imageRemoved->setProduct(null); @@ -3764,13 +3809,13 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related Image objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Image objects. * @throws PropelException */ - public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collImagesPartial && !$this->isNew(); if (null === $this->collImages || null !== $criteria || $partial) { @@ -3778,10 +3823,11 @@ abstract class BaseProduct extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getImages()); } - $query = ImageQuery::create(null, $criteria); + + $query = ChildImageQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3795,18 +3841,19 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Method called to associate a Image object to this object - * through the Image foreign key attribute. + * Method called to associate a ChildImage object to this object + * through the ChildImage foreign key attribute. * - * @param Image $l Image - * @return Product The current object (for fluent API support) + * @param ChildImage $l ChildImage + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addImage(Image $l) + public function addImage(ChildImage $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); } @@ -3815,7 +3862,7 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param Image $image The image object to add. + * @param Image $image The image object to add. */ protected function doAddImage($image) { @@ -3824,8 +3871,8 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param Image $image The image object to remove. - * @return Product The current object (for fluent API support) + * @param Image $image The image object to remove. + * @return ChildProduct The current object (for fluent API support) */ public function removeImage($image) { @@ -3854,15 +3901,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getImages($query, $con); } @@ -3879,15 +3926,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getImages($query, $con); } @@ -3904,15 +3951,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildImage[] List of ChildImage objects */ - public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getImagesJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildImageQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getImages($query, $con); } @@ -3923,21 +3970,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addDocuments() */ public function clearDocuments() { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - - return $this; + $this->collDocuments = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collDocuments collection loaded partially - * - * @return void + * Reset is the collDocuments collection loaded partially. */ public function resetPartialDocuments($v = true) { @@ -3951,7 +3993,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -3961,25 +4003,25 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null !== $this->collDocuments && !$overrideExisting) { return; } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); + $this->collDocuments = new ObjectCollection(); + $this->collDocuments->setModel('\Thelia\Model\Document'); } /** - * Gets an array of Document objects which contain a foreign key that references this object. + * Gets an array of ChildDocument objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildDocument[] List of ChildDocument objects * @throws PropelException */ - public function getDocuments($criteria = null, PropelPDO $con = null) + public function getDocuments($criteria = null, ConnectionInterface $con = null) { $partial = $this->collDocumentsPartial && !$this->isNew(); if (null === $this->collDocuments || null !== $criteria || $partial) { @@ -3987,29 +4029,31 @@ abstract class BaseProduct extends BaseObject implements Persistent // return empty collection $this->initDocuments(); } else { - $collDocuments = DocumentQuery::create(null, $criteria) + $collDocuments = ChildDocumentQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); + $this->initDocuments(false); - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); + foreach ($collDocuments as $obj) { + if (false == $this->collDocuments->contains($obj)) { + $this->collDocuments->append($obj); + } } - } - $this->collDocumentsPartial = true; + $this->collDocumentsPartial = true; } $collDocuments->getInternalIterator()->rewind(); + return $collDocuments; } - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { + if ($partial && $this->collDocuments) { + foreach ($this->collDocuments as $obj) { + if ($obj->isNew()) { $collDocuments[] = $obj; } } @@ -4029,15 +4073,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $documents A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) + public function setDocuments(Collection $documents, ConnectionInterface $con = null) { $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); + + $this->documentsScheduledForDeletion = $documentsToDelete; foreach ($documentsToDelete as $documentRemoved) { $documentRemoved->setProduct(null); @@ -4057,13 +4102,13 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related Document objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Document objects. * @throws PropelException */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countDocuments(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collDocumentsPartial && !$this->isNew(); if (null === $this->collDocuments || null !== $criteria || $partial) { @@ -4071,10 +4116,11 @@ abstract class BaseProduct extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getDocuments()); } - $query = DocumentQuery::create(null, $criteria); + + $query = ChildDocumentQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -4088,18 +4134,19 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. + * Method called to associate a ChildDocument object to this object + * through the ChildDocument foreign key attribute. * - * @param Document $l Document - * @return Product The current object (for fluent API support) + * @param ChildDocument $l ChildDocument + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addDocument(Document $l) + public function addDocument(ChildDocument $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); } @@ -4108,7 +4155,7 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param Document $document The document object to add. + * @param Document $document The document object to add. */ protected function doAddDocument($document) { @@ -4117,8 +4164,8 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param Document $document The document object to remove. - * @return Product The current object (for fluent API support) + * @param Document $document The document object to remove. + * @return ChildProduct The current object (for fluent API support) */ public function removeDocument($document) { @@ -4147,15 +4194,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getDocuments($query, $con); } @@ -4172,15 +4219,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getDocuments($query, $con); } @@ -4197,123 +4244,120 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildDocument[] List of ChildDocument objects */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getDocumentsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildDocumentQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getDocuments($query, $con); } /** - * Clears out the collAccessorysRelatedByProductId collection + * Clears out the collAccessoriesRelatedByProductId collection * * This 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 + * @see addAccessoriesRelatedByProductId() */ - public function resetPartialAccessorysRelatedByProductId($v = true) + public function clearAccessoriesRelatedByProductId() { - $this->collAccessorysRelatedByProductIdPartial = $v; + $this->collAccessoriesRelatedByProductId = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collAccessorysRelatedByProductId collection. + * Reset is the collAccessoriesRelatedByProductId collection loaded partially. + */ + public function resetPartialAccessoriesRelatedByProductId($v = true) + { + $this->collAccessoriesRelatedByProductIdPartial = $v; + } + + /** + * Initializes the collAccessoriesRelatedByProductId collection. * - * By default this just sets the collAccessorysRelatedByProductId collection to an empty array (like clearcollAccessorysRelatedByProductId()); + * By default this just sets the collAccessoriesRelatedByProductId collection to an empty array (like clearcollAccessoriesRelatedByProductId()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initAccessoriesRelatedByProductId($overrideExisting = true) { - if (null !== $this->collAccessorysRelatedByProductId && !$overrideExisting) { + if (null !== $this->collAccessoriesRelatedByProductId && !$overrideExisting) { return; } - $this->collAccessorysRelatedByProductId = new PropelObjectCollection(); - $this->collAccessorysRelatedByProductId->setModel('Accessory'); + $this->collAccessoriesRelatedByProductId = new ObjectCollection(); + $this->collAccessoriesRelatedByProductId->setModel('\Thelia\Model\Accessory'); } /** - * Gets an array of Accessory objects which contain a foreign key that references this object. + * Gets an array of ChildAccessory objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAccessory[] List of ChildAccessory objects * @throws PropelException */ - public function getAccessorysRelatedByProductId($criteria = null, PropelPDO $con = null) + public function getAccessoriesRelatedByProductId($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collAccessorysRelatedByProductIdPartial && !$this->isNew(); - if (null === $this->collAccessorysRelatedByProductId || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAccessorysRelatedByProductId) { + $partial = $this->collAccessoriesRelatedByProductIdPartial && !$this->isNew(); + if (null === $this->collAccessoriesRelatedByProductId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAccessoriesRelatedByProductId) { // return empty collection - $this->initAccessorysRelatedByProductId(); + $this->initAccessoriesRelatedByProductId(); } else { - $collAccessorysRelatedByProductId = AccessoryQuery::create(null, $criteria) + $collAccessoriesRelatedByProductId = ChildAccessoryQuery::create(null, $criteria) ->filterByProductRelatedByProductId($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collAccessorysRelatedByProductIdPartial && count($collAccessorysRelatedByProductId)) { - $this->initAccessorysRelatedByProductId(false); + if (false !== $this->collAccessoriesRelatedByProductIdPartial && count($collAccessoriesRelatedByProductId)) { + $this->initAccessoriesRelatedByProductId(false); - foreach($collAccessorysRelatedByProductId as $obj) { - if (false == $this->collAccessorysRelatedByProductId->contains($obj)) { - $this->collAccessorysRelatedByProductId->append($obj); + foreach ($collAccessoriesRelatedByProductId as $obj) { + if (false == $this->collAccessoriesRelatedByProductId->contains($obj)) { + $this->collAccessoriesRelatedByProductId->append($obj); + } } - } - $this->collAccessorysRelatedByProductIdPartial = true; + $this->collAccessoriesRelatedByProductIdPartial = true; } - $collAccessorysRelatedByProductId->getInternalIterator()->rewind(); - return $collAccessorysRelatedByProductId; + $collAccessoriesRelatedByProductId->getInternalIterator()->rewind(); + + return $collAccessoriesRelatedByProductId; } - if($partial && $this->collAccessorysRelatedByProductId) { - foreach($this->collAccessorysRelatedByProductId as $obj) { - if($obj->isNew()) { - $collAccessorysRelatedByProductId[] = $obj; + if ($partial && $this->collAccessoriesRelatedByProductId) { + foreach ($this->collAccessoriesRelatedByProductId as $obj) { + if ($obj->isNew()) { + $collAccessoriesRelatedByProductId[] = $obj; } } } - $this->collAccessorysRelatedByProductId = $collAccessorysRelatedByProductId; - $this->collAccessorysRelatedByProductIdPartial = false; + $this->collAccessoriesRelatedByProductId = $collAccessoriesRelatedByProductId; + $this->collAccessoriesRelatedByProductIdPartial = false; } } - return $this->collAccessorysRelatedByProductId; + return $this->collAccessoriesRelatedByProductId; } /** @@ -4322,27 +4366,28 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $accessoriesRelatedByProductId A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setAccessorysRelatedByProductId(PropelCollection $accessorysRelatedByProductId, PropelPDO $con = null) + public function setAccessoriesRelatedByProductId(Collection $accessoriesRelatedByProductId, ConnectionInterface $con = null) { - $accessorysRelatedByProductIdToDelete = $this->getAccessorysRelatedByProductId(new Criteria(), $con)->diff($accessorysRelatedByProductId); + $accessoriesRelatedByProductIdToDelete = $this->getAccessoriesRelatedByProductId(new Criteria(), $con)->diff($accessoriesRelatedByProductId); - $this->accessorysRelatedByProductIdScheduledForDeletion = unserialize(serialize($accessorysRelatedByProductIdToDelete)); - foreach ($accessorysRelatedByProductIdToDelete as $accessoryRelatedByProductIdRemoved) { + $this->accessoriesRelatedByProductIdScheduledForDeletion = $accessoriesRelatedByProductIdToDelete; + + foreach ($accessoriesRelatedByProductIdToDelete as $accessoryRelatedByProductIdRemoved) { $accessoryRelatedByProductIdRemoved->setProductRelatedByProductId(null); } - $this->collAccessorysRelatedByProductId = null; - foreach ($accessorysRelatedByProductId as $accessoryRelatedByProductId) { + $this->collAccessoriesRelatedByProductId = null; + foreach ($accessoriesRelatedByProductId as $accessoryRelatedByProductId) { $this->addAccessoryRelatedByProductId($accessoryRelatedByProductId); } - $this->collAccessorysRelatedByProductId = $accessorysRelatedByProductId; - $this->collAccessorysRelatedByProductIdPartial = false; + $this->collAccessoriesRelatedByProductId = $accessoriesRelatedByProductId; + $this->collAccessoriesRelatedByProductIdPartial = false; return $this; } @@ -4350,24 +4395,25 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related Accessory objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Accessory objects. * @throws PropelException */ - public function countAccessorysRelatedByProductId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAccessoriesRelatedByProductId(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collAccessorysRelatedByProductIdPartial && !$this->isNew(); - if (null === $this->collAccessorysRelatedByProductId || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAccessorysRelatedByProductId) { + $partial = $this->collAccessoriesRelatedByProductIdPartial && !$this->isNew(); + if (null === $this->collAccessoriesRelatedByProductId || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAccessoriesRelatedByProductId) { return 0; } - if($partial && !$criteria) { - return count($this->getAccessorysRelatedByProductId()); + if ($partial && !$criteria) { + return count($this->getAccessoriesRelatedByProductId()); } - $query = AccessoryQuery::create(null, $criteria); + + $query = ChildAccessoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -4377,23 +4423,24 @@ abstract class BaseProduct extends BaseObject implements Persistent ->count($con); } - return count($this->collAccessorysRelatedByProductId); + return count($this->collAccessoriesRelatedByProductId); } /** - * Method called to associate a Accessory object to this object - * through the Accessory foreign key attribute. + * Method called to associate a ChildAccessory object to this object + * through the ChildAccessory foreign key attribute. * - * @param Accessory $l Accessory - * @return Product The current object (for fluent API support) + * @param ChildAccessory $l ChildAccessory + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addAccessoryRelatedByProductId(Accessory $l) + public function addAccessoryRelatedByProductId(ChildAccessory $l) { - if ($this->collAccessorysRelatedByProductId === null) { - $this->initAccessorysRelatedByProductId(); - $this->collAccessorysRelatedByProductIdPartial = true; + if ($this->collAccessoriesRelatedByProductId === null) { + $this->initAccessoriesRelatedByProductId(); + $this->collAccessoriesRelatedByProductIdPartial = true; } - if (!in_array($l, $this->collAccessorysRelatedByProductId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collAccessoriesRelatedByProductId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAccessoryRelatedByProductId($l); } @@ -4401,27 +4448,27 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to add. + * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to add. */ protected function doAddAccessoryRelatedByProductId($accessoryRelatedByProductId) { - $this->collAccessorysRelatedByProductId[]= $accessoryRelatedByProductId; + $this->collAccessoriesRelatedByProductId[]= $accessoryRelatedByProductId; $accessoryRelatedByProductId->setProductRelatedByProductId($this); } /** - * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to remove. - * @return Product The current object (for fluent API support) + * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to remove. + * @return ChildProduct 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(); + if ($this->getAccessoriesRelatedByProductId()->contains($accessoryRelatedByProductId)) { + $this->collAccessoriesRelatedByProductId->remove($this->collAccessoriesRelatedByProductId->search($accessoryRelatedByProductId)); + if (null === $this->accessoriesRelatedByProductIdScheduledForDeletion) { + $this->accessoriesRelatedByProductIdScheduledForDeletion = clone $this->collAccessoriesRelatedByProductId; + $this->accessoriesRelatedByProductIdScheduledForDeletion->clear(); } - $this->accessorysRelatedByProductIdScheduledForDeletion[]= clone $accessoryRelatedByProductId; + $this->accessoriesRelatedByProductIdScheduledForDeletion[]= clone $accessoryRelatedByProductId; $accessoryRelatedByProductId->setProductRelatedByProductId(null); } @@ -4429,109 +4476,106 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Clears out the collAccessorysRelatedByAccessory collection + * Clears out the collAccessoriesRelatedByAccessory collection * * This 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 + * @see addAccessoriesRelatedByAccessory() */ - public function resetPartialAccessorysRelatedByAccessory($v = true) + public function clearAccessoriesRelatedByAccessory() { - $this->collAccessorysRelatedByAccessoryPartial = $v; + $this->collAccessoriesRelatedByAccessory = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collAccessorysRelatedByAccessory collection. + * Reset is the collAccessoriesRelatedByAccessory collection loaded partially. + */ + public function resetPartialAccessoriesRelatedByAccessory($v = true) + { + $this->collAccessoriesRelatedByAccessoryPartial = $v; + } + + /** + * Initializes the collAccessoriesRelatedByAccessory collection. * - * By default this just sets the collAccessorysRelatedByAccessory collection to an empty array (like clearcollAccessorysRelatedByAccessory()); + * By default this just sets the collAccessoriesRelatedByAccessory collection to an empty array (like clearcollAccessoriesRelatedByAccessory()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initAccessoriesRelatedByAccessory($overrideExisting = true) { - if (null !== $this->collAccessorysRelatedByAccessory && !$overrideExisting) { + if (null !== $this->collAccessoriesRelatedByAccessory && !$overrideExisting) { return; } - $this->collAccessorysRelatedByAccessory = new PropelObjectCollection(); - $this->collAccessorysRelatedByAccessory->setModel('Accessory'); + $this->collAccessoriesRelatedByAccessory = new ObjectCollection(); + $this->collAccessoriesRelatedByAccessory->setModel('\Thelia\Model\Accessory'); } /** - * Gets an array of Accessory objects which contain a foreign key that references this object. + * Gets an array of ChildAccessory objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAccessory[] List of ChildAccessory objects * @throws PropelException */ - public function getAccessorysRelatedByAccessory($criteria = null, PropelPDO $con = null) + public function getAccessoriesRelatedByAccessory($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collAccessorysRelatedByAccessoryPartial && !$this->isNew(); - if (null === $this->collAccessorysRelatedByAccessory || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAccessorysRelatedByAccessory) { + $partial = $this->collAccessoriesRelatedByAccessoryPartial && !$this->isNew(); + if (null === $this->collAccessoriesRelatedByAccessory || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAccessoriesRelatedByAccessory) { // return empty collection - $this->initAccessorysRelatedByAccessory(); + $this->initAccessoriesRelatedByAccessory(); } else { - $collAccessorysRelatedByAccessory = AccessoryQuery::create(null, $criteria) + $collAccessoriesRelatedByAccessory = ChildAccessoryQuery::create(null, $criteria) ->filterByProductRelatedByAccessory($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collAccessorysRelatedByAccessoryPartial && count($collAccessorysRelatedByAccessory)) { - $this->initAccessorysRelatedByAccessory(false); + if (false !== $this->collAccessoriesRelatedByAccessoryPartial && count($collAccessoriesRelatedByAccessory)) { + $this->initAccessoriesRelatedByAccessory(false); - foreach($collAccessorysRelatedByAccessory as $obj) { - if (false == $this->collAccessorysRelatedByAccessory->contains($obj)) { - $this->collAccessorysRelatedByAccessory->append($obj); + foreach ($collAccessoriesRelatedByAccessory as $obj) { + if (false == $this->collAccessoriesRelatedByAccessory->contains($obj)) { + $this->collAccessoriesRelatedByAccessory->append($obj); + } } - } - $this->collAccessorysRelatedByAccessoryPartial = true; + $this->collAccessoriesRelatedByAccessoryPartial = true; } - $collAccessorysRelatedByAccessory->getInternalIterator()->rewind(); - return $collAccessorysRelatedByAccessory; + $collAccessoriesRelatedByAccessory->getInternalIterator()->rewind(); + + return $collAccessoriesRelatedByAccessory; } - if($partial && $this->collAccessorysRelatedByAccessory) { - foreach($this->collAccessorysRelatedByAccessory as $obj) { - if($obj->isNew()) { - $collAccessorysRelatedByAccessory[] = $obj; + if ($partial && $this->collAccessoriesRelatedByAccessory) { + foreach ($this->collAccessoriesRelatedByAccessory as $obj) { + if ($obj->isNew()) { + $collAccessoriesRelatedByAccessory[] = $obj; } } } - $this->collAccessorysRelatedByAccessory = $collAccessorysRelatedByAccessory; - $this->collAccessorysRelatedByAccessoryPartial = false; + $this->collAccessoriesRelatedByAccessory = $collAccessoriesRelatedByAccessory; + $this->collAccessoriesRelatedByAccessoryPartial = false; } } - return $this->collAccessorysRelatedByAccessory; + return $this->collAccessoriesRelatedByAccessory; } /** @@ -4540,27 +4584,28 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $accessoriesRelatedByAccessory A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setAccessorysRelatedByAccessory(PropelCollection $accessorysRelatedByAccessory, PropelPDO $con = null) + public function setAccessoriesRelatedByAccessory(Collection $accessoriesRelatedByAccessory, ConnectionInterface $con = null) { - $accessorysRelatedByAccessoryToDelete = $this->getAccessorysRelatedByAccessory(new Criteria(), $con)->diff($accessorysRelatedByAccessory); + $accessoriesRelatedByAccessoryToDelete = $this->getAccessoriesRelatedByAccessory(new Criteria(), $con)->diff($accessoriesRelatedByAccessory); - $this->accessorysRelatedByAccessoryScheduledForDeletion = unserialize(serialize($accessorysRelatedByAccessoryToDelete)); - foreach ($accessorysRelatedByAccessoryToDelete as $accessoryRelatedByAccessoryRemoved) { + $this->accessoriesRelatedByAccessoryScheduledForDeletion = $accessoriesRelatedByAccessoryToDelete; + + foreach ($accessoriesRelatedByAccessoryToDelete as $accessoryRelatedByAccessoryRemoved) { $accessoryRelatedByAccessoryRemoved->setProductRelatedByAccessory(null); } - $this->collAccessorysRelatedByAccessory = null; - foreach ($accessorysRelatedByAccessory as $accessoryRelatedByAccessory) { + $this->collAccessoriesRelatedByAccessory = null; + foreach ($accessoriesRelatedByAccessory as $accessoryRelatedByAccessory) { $this->addAccessoryRelatedByAccessory($accessoryRelatedByAccessory); } - $this->collAccessorysRelatedByAccessory = $accessorysRelatedByAccessory; - $this->collAccessorysRelatedByAccessoryPartial = false; + $this->collAccessoriesRelatedByAccessory = $accessoriesRelatedByAccessory; + $this->collAccessoriesRelatedByAccessoryPartial = false; return $this; } @@ -4568,24 +4613,25 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related Accessory objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Accessory objects. * @throws PropelException */ - public function countAccessorysRelatedByAccessory(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countAccessoriesRelatedByAccessory(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collAccessorysRelatedByAccessoryPartial && !$this->isNew(); - if (null === $this->collAccessorysRelatedByAccessory || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAccessorysRelatedByAccessory) { + $partial = $this->collAccessoriesRelatedByAccessoryPartial && !$this->isNew(); + if (null === $this->collAccessoriesRelatedByAccessory || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAccessoriesRelatedByAccessory) { return 0; } - if($partial && !$criteria) { - return count($this->getAccessorysRelatedByAccessory()); + if ($partial && !$criteria) { + return count($this->getAccessoriesRelatedByAccessory()); } - $query = AccessoryQuery::create(null, $criteria); + + $query = ChildAccessoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -4595,23 +4641,24 @@ abstract class BaseProduct extends BaseObject implements Persistent ->count($con); } - return count($this->collAccessorysRelatedByAccessory); + return count($this->collAccessoriesRelatedByAccessory); } /** - * Method called to associate a Accessory object to this object - * through the Accessory foreign key attribute. + * Method called to associate a ChildAccessory object to this object + * through the ChildAccessory foreign key attribute. * - * @param Accessory $l Accessory - * @return Product The current object (for fluent API support) + * @param ChildAccessory $l ChildAccessory + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addAccessoryRelatedByAccessory(Accessory $l) + public function addAccessoryRelatedByAccessory(ChildAccessory $l) { - if ($this->collAccessorysRelatedByAccessory === null) { - $this->initAccessorysRelatedByAccessory(); - $this->collAccessorysRelatedByAccessoryPartial = true; + if ($this->collAccessoriesRelatedByAccessory === null) { + $this->initAccessoriesRelatedByAccessory(); + $this->collAccessoriesRelatedByAccessoryPartial = true; } - if (!in_array($l, $this->collAccessorysRelatedByAccessory->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collAccessoriesRelatedByAccessory->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddAccessoryRelatedByAccessory($l); } @@ -4619,27 +4666,27 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to add. + * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to add. */ protected function doAddAccessoryRelatedByAccessory($accessoryRelatedByAccessory) { - $this->collAccessorysRelatedByAccessory[]= $accessoryRelatedByAccessory; + $this->collAccessoriesRelatedByAccessory[]= $accessoryRelatedByAccessory; $accessoryRelatedByAccessory->setProductRelatedByAccessory($this); } /** - * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to remove. - * @return Product The current object (for fluent API support) + * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to remove. + * @return ChildProduct 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(); + if ($this->getAccessoriesRelatedByAccessory()->contains($accessoryRelatedByAccessory)) { + $this->collAccessoriesRelatedByAccessory->remove($this->collAccessoriesRelatedByAccessory->search($accessoryRelatedByAccessory)); + if (null === $this->accessoriesRelatedByAccessoryScheduledForDeletion) { + $this->accessoriesRelatedByAccessoryScheduledForDeletion = clone $this->collAccessoriesRelatedByAccessory; + $this->accessoriesRelatedByAccessoryScheduledForDeletion->clear(); } - $this->accessorysRelatedByAccessoryScheduledForDeletion[]= clone $accessoryRelatedByAccessory; + $this->accessoriesRelatedByAccessoryScheduledForDeletion[]= clone $accessoryRelatedByAccessory; $accessoryRelatedByAccessory->setProductRelatedByAccessory(null); } @@ -4652,21 +4699,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addRewritings() */ public function clearRewritings() { - $this->collRewritings = null; // important to set this to null since that means it is uninitialized - $this->collRewritingsPartial = null; - - return $this; + $this->collRewritings = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collRewritings collection loaded partially - * - * @return void + * Reset is the collRewritings collection loaded partially. */ public function resetPartialRewritings($v = true) { @@ -4680,7 +4722,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -4690,25 +4732,25 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null !== $this->collRewritings && !$overrideExisting) { return; } - $this->collRewritings = new PropelObjectCollection(); - $this->collRewritings->setModel('Rewriting'); + $this->collRewritings = new ObjectCollection(); + $this->collRewritings->setModel('\Thelia\Model\Rewriting'); } /** - * Gets an array of Rewriting objects which contain a foreign key that references this object. + * Gets an array of ChildRewriting objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildRewriting[] List of ChildRewriting objects * @throws PropelException */ - public function getRewritings($criteria = null, PropelPDO $con = null) + public function getRewritings($criteria = null, ConnectionInterface $con = null) { $partial = $this->collRewritingsPartial && !$this->isNew(); if (null === $this->collRewritings || null !== $criteria || $partial) { @@ -4716,29 +4758,31 @@ abstract class BaseProduct extends BaseObject implements Persistent // return empty collection $this->initRewritings(); } else { - $collRewritings = RewritingQuery::create(null, $criteria) + $collRewritings = ChildRewritingQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); + $this->initRewritings(false); - foreach($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); + foreach ($collRewritings as $obj) { + if (false == $this->collRewritings->contains($obj)) { + $this->collRewritings->append($obj); + } } - } - $this->collRewritingsPartial = true; + $this->collRewritingsPartial = true; } $collRewritings->getInternalIterator()->rewind(); + return $collRewritings; } - if($partial && $this->collRewritings) { - foreach($this->collRewritings as $obj) { - if($obj->isNew()) { + if ($partial && $this->collRewritings) { + foreach ($this->collRewritings as $obj) { + if ($obj->isNew()) { $collRewritings[] = $obj; } } @@ -4758,15 +4802,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $rewritings A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) + public function setRewritings(Collection $rewritings, ConnectionInterface $con = null) { $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); + + $this->rewritingsScheduledForDeletion = $rewritingsToDelete; foreach ($rewritingsToDelete as $rewritingRemoved) { $rewritingRemoved->setProduct(null); @@ -4786,13 +4831,13 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related Rewriting objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Rewriting objects. * @throws PropelException */ - public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countRewritings(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRewritingsPartial && !$this->isNew(); if (null === $this->collRewritings || null !== $criteria || $partial) { @@ -4800,10 +4845,11 @@ abstract class BaseProduct extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getRewritings()); } - $query = RewritingQuery::create(null, $criteria); + + $query = ChildRewritingQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -4817,18 +4863,19 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Method called to associate a Rewriting object to this object - * through the Rewriting foreign key attribute. + * Method called to associate a ChildRewriting object to this object + * through the ChildRewriting foreign key attribute. * - * @param Rewriting $l Rewriting - * @return Product The current object (for fluent API support) + * @param ChildRewriting $l ChildRewriting + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addRewriting(Rewriting $l) + public function addRewriting(ChildRewriting $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); } @@ -4837,7 +4884,7 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param Rewriting $rewriting The rewriting object to add. + * @param Rewriting $rewriting The rewriting object to add. */ protected function doAddRewriting($rewriting) { @@ -4846,8 +4893,8 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return Product The current object (for fluent API support) + * @param Rewriting $rewriting The rewriting object to remove. + * @return ChildProduct The current object (for fluent API support) */ public function removeRewriting($rewriting) { @@ -4876,15 +4923,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinCategory($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Category', $joinBehavior); return $this->getRewritings($query, $con); } @@ -4901,15 +4948,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinFolder($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Folder', $joinBehavior); return $this->getRewritings($query, $con); } @@ -4926,15 +4973,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildRewriting[] List of ChildRewriting objects */ - public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getRewritingsJoinContent($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); + $query = ChildRewritingQuery::create(null, $criteria); + $query->joinWith('Content', $joinBehavior); return $this->getRewritings($query, $con); } @@ -4945,21 +4992,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collProductI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collProductI18ns collection loaded partially - * - * @return void + * Reset is the collProductI18ns collection loaded partially. */ public function resetPartialProductI18ns($v = true) { @@ -4973,7 +5015,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -4983,25 +5025,25 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null !== $this->collProductI18ns && !$overrideExisting) { return; } - $this->collProductI18ns = new PropelObjectCollection(); - $this->collProductI18ns->setModel('ProductI18n'); + $this->collProductI18ns = new ObjectCollection(); + $this->collProductI18ns->setModel('\Thelia\Model\ProductI18n'); } /** - * Gets an array of ProductI18n objects which contain a foreign key that references this object. + * Gets an array of ChildProductI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProductI18n[] List of ChildProductI18n objects * @throws PropelException */ - public function getProductI18ns($criteria = null, PropelPDO $con = null) + public function getProductI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collProductI18nsPartial && !$this->isNew(); if (null === $this->collProductI18ns || null !== $criteria || $partial) { @@ -5009,29 +5051,31 @@ abstract class BaseProduct extends BaseObject implements Persistent // return empty collection $this->initProductI18ns(); } else { - $collProductI18ns = ProductI18nQuery::create(null, $criteria) + $collProductI18ns = ChildProductI18nQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collProductI18nsPartial && count($collProductI18ns)) { - $this->initProductI18ns(false); + $this->initProductI18ns(false); - foreach($collProductI18ns as $obj) { - if (false == $this->collProductI18ns->contains($obj)) { - $this->collProductI18ns->append($obj); + foreach ($collProductI18ns as $obj) { + if (false == $this->collProductI18ns->contains($obj)) { + $this->collProductI18ns->append($obj); + } } - } - $this->collProductI18nsPartial = true; + $this->collProductI18nsPartial = true; } $collProductI18ns->getInternalIterator()->rewind(); + return $collProductI18ns; } - if($partial && $this->collProductI18ns) { - foreach($this->collProductI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collProductI18ns) { + foreach ($this->collProductI18ns as $obj) { + if ($obj->isNew()) { $collProductI18ns[] = $obj; } } @@ -5051,15 +5095,19 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $productI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setProductI18ns(PropelCollection $productI18ns, PropelPDO $con = null) + public function setProductI18ns(Collection $productI18ns, ConnectionInterface $con = null) { $productI18nsToDelete = $this->getProductI18ns(new Criteria(), $con)->diff($productI18ns); - $this->productI18nsScheduledForDeletion = unserialize(serialize($productI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->productI18nsScheduledForDeletion = clone $productI18nsToDelete; foreach ($productI18nsToDelete as $productI18nRemoved) { $productI18nRemoved->setProduct(null); @@ -5079,13 +5127,13 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related ProductI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ProductI18n objects. * @throws PropelException */ - public function countProductI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countProductI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collProductI18nsPartial && !$this->isNew(); if (null === $this->collProductI18ns || null !== $criteria || $partial) { @@ -5093,10 +5141,11 @@ abstract class BaseProduct extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getProductI18ns()); } - $query = ProductI18nQuery::create(null, $criteria); + + $query = ChildProductI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -5110,13 +5159,13 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Method called to associate a ProductI18n object to this object - * through the ProductI18n foreign key attribute. + * Method called to associate a ChildProductI18n object to this object + * through the ChildProductI18n foreign key attribute. * - * @param ProductI18n $l ProductI18n - * @return Product The current object (for fluent API support) + * @param ChildProductI18n $l ChildProductI18n + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addProductI18n(ProductI18n $l) + public function addProductI18n(ChildProductI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -5126,6 +5175,7 @@ abstract class BaseProduct extends BaseObject implements Persistent $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); } @@ -5134,7 +5184,7 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param ProductI18n $productI18n The productI18n object to add. + * @param ProductI18n $productI18n The productI18n object to add. */ protected function doAddProductI18n($productI18n) { @@ -5143,8 +5193,8 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param ProductI18n $productI18n The productI18n object to remove. - * @return Product The current object (for fluent API support) + * @param ProductI18n $productI18n The productI18n object to remove. + * @return ChildProduct The current object (for fluent API support) */ public function removeProductI18n($productI18n) { @@ -5167,21 +5217,16 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addProductVersions() */ public function clearProductVersions() { - $this->collProductVersions = null; // important to set this to null since that means it is uninitialized - $this->collProductVersionsPartial = null; - - return $this; + $this->collProductVersions = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collProductVersions collection loaded partially - * - * @return void + * Reset is the collProductVersions collection loaded partially. */ public function resetPartialProductVersions($v = true) { @@ -5195,7 +5240,7 @@ abstract class BaseProduct extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -5205,25 +5250,25 @@ abstract class BaseProduct extends BaseObject implements Persistent if (null !== $this->collProductVersions && !$overrideExisting) { return; } - $this->collProductVersions = new PropelObjectCollection(); - $this->collProductVersions->setModel('ProductVersion'); + $this->collProductVersions = new ObjectCollection(); + $this->collProductVersions->setModel('\Thelia\Model\ProductVersion'); } /** - * Gets an array of ProductVersion objects which contain a foreign key that references this object. + * Gets an array of ChildProductVersion objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildProduct is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProductVersion[] List of ChildProductVersion objects * @throws PropelException */ - public function getProductVersions($criteria = null, PropelPDO $con = null) + public function getProductVersions($criteria = null, ConnectionInterface $con = null) { $partial = $this->collProductVersionsPartial && !$this->isNew(); if (null === $this->collProductVersions || null !== $criteria || $partial) { @@ -5231,29 +5276,31 @@ abstract class BaseProduct extends BaseObject implements Persistent // return empty collection $this->initProductVersions(); } else { - $collProductVersions = ProductVersionQuery::create(null, $criteria) + $collProductVersions = ChildProductVersionQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collProductVersionsPartial && count($collProductVersions)) { - $this->initProductVersions(false); + $this->initProductVersions(false); - foreach($collProductVersions as $obj) { - if (false == $this->collProductVersions->contains($obj)) { - $this->collProductVersions->append($obj); + foreach ($collProductVersions as $obj) { + if (false == $this->collProductVersions->contains($obj)) { + $this->collProductVersions->append($obj); + } } - } - $this->collProductVersionsPartial = true; + $this->collProductVersionsPartial = true; } $collProductVersions->getInternalIterator()->rewind(); + return $collProductVersions; } - if($partial && $this->collProductVersions) { - foreach($this->collProductVersions as $obj) { - if($obj->isNew()) { + if ($partial && $this->collProductVersions) { + foreach ($this->collProductVersions as $obj) { + if ($obj->isNew()) { $collProductVersions[] = $obj; } } @@ -5273,15 +5320,19 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $productVersions A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setProductVersions(PropelCollection $productVersions, PropelPDO $con = null) + public function setProductVersions(Collection $productVersions, ConnectionInterface $con = null) { $productVersionsToDelete = $this->getProductVersions(new Criteria(), $con)->diff($productVersions); - $this->productVersionsScheduledForDeletion = unserialize(serialize($productVersionsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->productVersionsScheduledForDeletion = clone $productVersionsToDelete; foreach ($productVersionsToDelete as $productVersionRemoved) { $productVersionRemoved->setProduct(null); @@ -5301,13 +5352,13 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the number of related ProductVersion objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ProductVersion objects. * @throws PropelException */ - public function countProductVersions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countProductVersions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collProductVersionsPartial && !$this->isNew(); if (null === $this->collProductVersions || null !== $criteria || $partial) { @@ -5315,10 +5366,11 @@ abstract class BaseProduct extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getProductVersions()); } - $query = ProductVersionQuery::create(null, $criteria); + + $query = ChildProductVersionQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -5332,18 +5384,19 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Method called to associate a ProductVersion object to this object - * through the ProductVersion foreign key attribute. + * Method called to associate a ChildProductVersion object to this object + * through the ChildProductVersion foreign key attribute. * - * @param ProductVersion $l ProductVersion - * @return Product The current object (for fluent API support) + * @param ChildProductVersion $l ChildProductVersion + * @return \Thelia\Model\Product The current object (for fluent API support) */ - public function addProductVersion(ProductVersion $l) + public function addProductVersion(ChildProductVersion $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); } @@ -5352,7 +5405,7 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param ProductVersion $productVersion The productVersion object to add. + * @param ProductVersion $productVersion The productVersion object to add. */ protected function doAddProductVersion($productVersion) { @@ -5361,8 +5414,8 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * @param ProductVersion $productVersion The productVersion object to remove. - * @return Product The current object (for fluent API support) + * @param ProductVersion $productVersion The productVersion object to remove. + * @return ChildProduct The current object (for fluent API support) */ public function removeProductVersion($productVersion) { @@ -5380,70 +5433,68 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Clears out the collCategorys collection + * Clears out the collCategories collection * * This 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() + * @return void + * @see addCategories() */ - public function clearCategorys() + public function clearCategories() { - $this->collCategorys = null; // important to set this to null since that means it is uninitialized - $this->collCategorysPartial = null; - - return $this; + $this->collCategories = null; // important to set this to NULL since that means it is uninitialized + $this->collCategoriesPartial = null; } /** - * Initializes the collCategorys collection. + * Initializes the collCategories collection. * - * By default this just sets the collCategorys collection to an empty collection (like clearCategorys()); + * By default this just sets the collCategories collection to an empty collection (like clearCategories()); * however, you may wish to override this 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() + public function initCategories() { - $this->collCategorys = new PropelObjectCollection(); - $this->collCategorys->setModel('Category'); + $this->collCategories = new ObjectCollection(); + $this->collCategories->setModel('\Thelia\Model\Category'); } /** - * Gets a collection of Category objects related by a many-to-many relationship + * Gets a collection of ChildCategory 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 + * If this ChildProduct 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Category[] List of Category objects + * @return ObjectCollection|ChildCategory[] List of ChildCategory objects */ - public function getCategorys($criteria = null, PropelPDO $con = null) + public function getCategories($criteria = null, ConnectionInterface $con = null) { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { + if (null === $this->collCategories || null !== $criteria) { + if ($this->isNew() && null === $this->collCategories) { // return empty collection - $this->initCategorys(); + $this->initCategories(); } else { - $collCategorys = CategoryQuery::create(null, $criteria) + $collCategories = ChildCategoryQuery::create(null, $criteria) ->filterByProduct($this) ->find($con); if (null !== $criteria) { - return $collCategorys; + return $collCategories; } - $this->collCategorys = $collCategorys; + $this->collCategories = $collCategories; } } - return $this->collCategorys; + return $this->collCategories; } /** @@ -5452,45 +5503,45 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $categories A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setCategorys(PropelCollection $categorys, PropelPDO $con = null) + public function setCategories(Collection $categories, ConnectionInterface $con = null) { - $this->clearCategorys(); - $currentCategorys = $this->getCategorys(); + $this->clearCategories(); + $currentCategories = $this->getCategories(); - $this->categorysScheduledForDeletion = $currentCategorys->diff($categorys); + $this->categoriesScheduledForDeletion = $currentCategories->diff($categories); - foreach ($categorys as $category) { - if (!$currentCategorys->contains($category)) { + foreach ($categories as $category) { + if (!$currentCategories->contains($category)) { $this->doAddCategory($category); } } - $this->collCategorys = $categorys; + $this->collCategories = $categories; return $this; } /** - * Gets the number of Category objects related by a many-to-many relationship + * Gets the number of ChildCategory 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Category objects + * @return int the number of related ChildCategory objects */ - public function countCategorys($criteria = null, $distinct = false, PropelPDO $con = null) + public function countCategories($criteria = null, $distinct = false, ConnectionInterface $con = null) { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { + if (null === $this->collCategories || null !== $criteria) { + if ($this->isNew() && null === $this->collCategories) { return 0; } else { - $query = CategoryQuery::create(null, $criteria); + $query = ChildCategoryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -5500,57 +5551,65 @@ abstract class BaseProduct extends BaseObject implements Persistent ->count($con); } } else { - return count($this->collCategorys); + return count($this->collCategories); } } /** - * Associate a Category object to this object + * Associate a ChildCategory 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) + * @param ChildCategory $category The ChildProductCategory object to relate + * @return ChildProduct The current object (for fluent API support) */ - public function addCategory(Category $category) + public function addCategory(ChildCategory $category) { - if ($this->collCategorys === null) { - $this->initCategorys(); + if ($this->collCategories === null) { + $this->initCategories(); } - if (!$this->collCategorys->contains($category)) { // only add it if the **same** object is not already associated - $this->doAddCategory($category); - $this->collCategorys[]= $category; + if (!$this->collCategories->contains($category)) { // only add it if the **same** object is not already associated + $this->doAddCategory($category); + $this->collCategories[] = $category; } return $this; } /** - * @param Category $category The category object to add. + * @param Category $category The category object to add. */ protected function doAddCategory($category) { - $productCategory = new ProductCategory(); + $productCategory = new ChildProductCategory(); $productCategory->setCategory($category); $this->addProductCategory($productCategory); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$category->getProducts()->contains($this)) { + $foreignCollection = $category->getProducts(); + $foreignCollection[] = $this; + } } /** - * Remove a Category object to this object + * Remove a ChildCategory 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) + * @param ChildCategory $category The ChildProductCategory object to relate + * @return ChildProduct The current object (for fluent API support) */ - public function removeCategory(Category $category) + public function removeCategory(ChildCategory $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(); + if ($this->getCategories()->contains($category)) { + $this->collCategories->remove($this->collCategories->search($category)); + + if (null === $this->categoriesScheduledForDeletion) { + $this->categoriesScheduledForDeletion = clone $this->collCategories; + $this->categoriesScheduledForDeletion->clear(); } - $this->categorysScheduledForDeletion[]= $category; + + $this->categoriesScheduledForDeletion[] = $category; } return $this; @@ -5562,15 +5621,13 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addProductsRelatedByAccessory() */ public function clearProductsRelatedByAccessory() { - $this->collProductsRelatedByAccessory = null; // important to set this to null since that means it is uninitialized + $this->collProductsRelatedByAccessory = null; // important to set this to NULL since that means it is uninitialized $this->collProductsRelatedByAccessoryPartial = null; - - return $this; } /** @@ -5584,33 +5641,33 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function initProductsRelatedByAccessory() { - $this->collProductsRelatedByAccessory = new PropelObjectCollection(); - $this->collProductsRelatedByAccessory->setModel('Product'); + $this->collProductsRelatedByAccessory = new ObjectCollection(); + $this->collProductsRelatedByAccessory->setModel('\Thelia\Model\Product'); } /** - * Gets a collection of Product objects related by a many-to-many relationship + * Gets a collection of ChildProduct 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 + * If this ChildProduct 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Product[] List of Product objects + * @return ObjectCollection|ChildProduct[] List of ChildProduct objects */ - public function getProductsRelatedByAccessory($criteria = null, PropelPDO $con = null) + public function getProductsRelatedByAccessory($criteria = null, ConnectionInterface $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) + $collProductsRelatedByAccessory = ChildProductQuery::create(null, $criteria) ->filterByProductRelatedByProductId($this) ->find($con); if (null !== $criteria) { @@ -5629,11 +5686,11 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $productsRelatedByAccessory A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setProductsRelatedByAccessory(PropelCollection $productsRelatedByAccessory, PropelPDO $con = null) + public function setProductsRelatedByAccessory(Collection $productsRelatedByAccessory, ConnectionInterface $con = null) { $this->clearProductsRelatedByAccessory(); $currentProductsRelatedByAccessory = $this->getProductsRelatedByAccessory(); @@ -5652,22 +5709,22 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Gets the number of Product objects related by a many-to-many relationship + * Gets the number of ChildProduct 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Product objects + * @return int the number of related ChildProduct objects */ - public function countProductsRelatedByAccessory($criteria = null, $distinct = false, PropelPDO $con = null) + public function countProductsRelatedByAccessory($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collProductsRelatedByAccessory || null !== $criteria) { if ($this->isNew() && null === $this->collProductsRelatedByAccessory) { return 0; } else { - $query = ProductQuery::create(null, $criteria); + $query = ChildProductQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -5682,52 +5739,60 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Associate a Product object to this object + * Associate a ChildProduct 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) + * @param ChildProduct $product The ChildAccessory object to relate + * @return ChildProduct The current object (for fluent API support) */ - public function addProductRelatedByAccessory(Product $product) + public function addProductRelatedByAccessory(ChildProduct $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; + $this->collProductsRelatedByAccessory[] = $product; } return $this; } /** - * @param ProductRelatedByAccessory $productRelatedByAccessory The productRelatedByAccessory object to add. + * @param ProductRelatedByAccessory $productRelatedByAccessory The productRelatedByAccessory object to add. */ protected function doAddProductRelatedByAccessory($productRelatedByAccessory) { - $accessory = new Accessory(); + $accessory = new ChildAccessory(); $accessory->setProductRelatedByAccessory($productRelatedByAccessory); $this->addAccessoryRelatedByProductId($accessory); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$productRelatedByAccessory->getProductsRelatedByProductId()->contains($this)) { + $foreignCollection = $productRelatedByAccessory->getProductsRelatedByProductId(); + $foreignCollection[] = $this; + } } /** - * Remove a Product object to this object + * Remove a ChildProduct 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) + * @param ChildProduct $product The ChildAccessory object to relate + * @return ChildProduct The current object (for fluent API support) */ - public function removeProductRelatedByAccessory(Product $product) + public function removeProductRelatedByAccessory(ChildProduct $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; + + $this->productsRelatedByAccessoryScheduledForDeletion[] = $product; } return $this; @@ -5739,15 +5804,13 @@ abstract class BaseProduct extends BaseObject implements Persistent * This 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) + * @return void * @see addProductsRelatedByProductId() */ public function clearProductsRelatedByProductId() { - $this->collProductsRelatedByProductId = null; // important to set this to null since that means it is uninitialized + $this->collProductsRelatedByProductId = null; // important to set this to NULL since that means it is uninitialized $this->collProductsRelatedByProductIdPartial = null; - - return $this; } /** @@ -5761,33 +5824,33 @@ abstract class BaseProduct extends BaseObject implements Persistent */ public function initProductsRelatedByProductId() { - $this->collProductsRelatedByProductId = new PropelObjectCollection(); - $this->collProductsRelatedByProductId->setModel('Product'); + $this->collProductsRelatedByProductId = new ObjectCollection(); + $this->collProductsRelatedByProductId->setModel('\Thelia\Model\Product'); } /** - * Gets a collection of Product objects related by a many-to-many relationship + * Gets a collection of ChildProduct 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 + * If this ChildProduct 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Product[] List of Product objects + * @return ObjectCollection|ChildProduct[] List of ChildProduct objects */ - public function getProductsRelatedByProductId($criteria = null, PropelPDO $con = null) + public function getProductsRelatedByProductId($criteria = null, ConnectionInterface $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) + $collProductsRelatedByProductId = ChildProductQuery::create(null, $criteria) ->filterByProductRelatedByAccessory($this) ->find($con); if (null !== $criteria) { @@ -5806,11 +5869,11 @@ abstract class BaseProduct extends BaseObject implements Persistent * It will 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) + * @param Collection $productsRelatedByProductId A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProduct The current object (for fluent API support) */ - public function setProductsRelatedByProductId(PropelCollection $productsRelatedByProductId, PropelPDO $con = null) + public function setProductsRelatedByProductId(Collection $productsRelatedByProductId, ConnectionInterface $con = null) { $this->clearProductsRelatedByProductId(); $currentProductsRelatedByProductId = $this->getProductsRelatedByProductId(); @@ -5829,22 +5892,22 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Gets the number of Product objects related by a many-to-many relationship + * Gets the number of ChildProduct 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Product objects + * @return int the number of related ChildProduct objects */ - public function countProductsRelatedByProductId($criteria = null, $distinct = false, PropelPDO $con = null) + public function countProductsRelatedByProductId($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collProductsRelatedByProductId || null !== $criteria) { if ($this->isNew() && null === $this->collProductsRelatedByProductId) { return 0; } else { - $query = ProductQuery::create(null, $criteria); + $query = ChildProductQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -5859,52 +5922,60 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Associate a Product object to this object + * Associate a ChildProduct 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) + * @param ChildProduct $product The ChildAccessory object to relate + * @return ChildProduct The current object (for fluent API support) */ - public function addProductRelatedByProductId(Product $product) + public function addProductRelatedByProductId(ChildProduct $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; + $this->collProductsRelatedByProductId[] = $product; } return $this; } /** - * @param ProductRelatedByProductId $productRelatedByProductId The productRelatedByProductId object to add. + * @param ProductRelatedByProductId $productRelatedByProductId The productRelatedByProductId object to add. */ protected function doAddProductRelatedByProductId($productRelatedByProductId) { - $accessory = new Accessory(); + $accessory = new ChildAccessory(); $accessory->setProductRelatedByProductId($productRelatedByProductId); $this->addAccessoryRelatedByAccessory($accessory); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$productRelatedByProductId->getProductsRelatedByAccessory()->contains($this)) { + $foreignCollection = $productRelatedByProductId->getProductsRelatedByAccessory(); + $foreignCollection[] = $this; + } } /** - * Remove a Product object to this object + * Remove a ChildProduct 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) + * @param ChildProduct $product The ChildAccessory object to relate + * @return ChildProduct The current object (for fluent API support) */ - public function removeProductRelatedByProductId(Product $product) + public function removeProductRelatedByProductId(ChildProduct $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; + + $this->productsRelatedByProductIdScheduledForDeletion[] = $product; } return $this; @@ -5933,8 +6004,6 @@ abstract class BaseProduct extends BaseObject implements Persistent $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(); @@ -5947,16 +6016,15 @@ abstract class BaseProduct extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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) { + if ($deep) { + if ($this->collProductCategories) { + foreach ($this->collProductCategories as $o) { $o->clearAllReferences($deep); } } @@ -5985,13 +6053,13 @@ abstract class BaseProduct extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->collAccessorysRelatedByProductId) { - foreach ($this->collAccessorysRelatedByProductId as $o) { + if ($this->collAccessoriesRelatedByProductId) { + foreach ($this->collAccessoriesRelatedByProductId as $o) { $o->clearAllReferences($deep); } } - if ($this->collAccessorysRelatedByAccessory) { - foreach ($this->collAccessorysRelatedByAccessory as $o) { + if ($this->collAccessoriesRelatedByAccessory) { + foreach ($this->collAccessoriesRelatedByAccessory as $o) { $o->clearAllReferences($deep); } } @@ -6010,8 +6078,8 @@ abstract class BaseProduct extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->collCategorys) { - foreach ($this->collCategorys as $o) { + if ($this->collCategories) { + foreach ($this->collCategories as $o) { $o->clearAllReferences($deep); } } @@ -6025,70 +6093,65 @@ abstract class BaseProduct extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - if ($this->aTaxRule instanceof Persistent) { - $this->aTaxRule->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collProductCategorys instanceof PropelCollection) { - $this->collProductCategorys->clearIterator(); + if ($this->collProductCategories instanceof Collection) { + $this->collProductCategories->clearIterator(); } - $this->collProductCategorys = null; - if ($this->collFeatureProds instanceof PropelCollection) { + $this->collProductCategories = null; + if ($this->collFeatureProds instanceof Collection) { $this->collFeatureProds->clearIterator(); } $this->collFeatureProds = null; - if ($this->collStocks instanceof PropelCollection) { + if ($this->collStocks instanceof Collection) { $this->collStocks->clearIterator(); } $this->collStocks = null; - if ($this->collContentAssocs instanceof PropelCollection) { + if ($this->collContentAssocs instanceof Collection) { $this->collContentAssocs->clearIterator(); } $this->collContentAssocs = null; - if ($this->collImages instanceof PropelCollection) { + if ($this->collImages instanceof Collection) { $this->collImages->clearIterator(); } $this->collImages = null; - if ($this->collDocuments instanceof PropelCollection) { + if ($this->collDocuments instanceof Collection) { $this->collDocuments->clearIterator(); } $this->collDocuments = null; - if ($this->collAccessorysRelatedByProductId instanceof PropelCollection) { - $this->collAccessorysRelatedByProductId->clearIterator(); + if ($this->collAccessoriesRelatedByProductId instanceof Collection) { + $this->collAccessoriesRelatedByProductId->clearIterator(); } - $this->collAccessorysRelatedByProductId = null; - if ($this->collAccessorysRelatedByAccessory instanceof PropelCollection) { - $this->collAccessorysRelatedByAccessory->clearIterator(); + $this->collAccessoriesRelatedByProductId = null; + if ($this->collAccessoriesRelatedByAccessory instanceof Collection) { + $this->collAccessoriesRelatedByAccessory->clearIterator(); } - $this->collAccessorysRelatedByAccessory = null; - if ($this->collRewritings instanceof PropelCollection) { + $this->collAccessoriesRelatedByAccessory = null; + if ($this->collRewritings instanceof Collection) { $this->collRewritings->clearIterator(); } $this->collRewritings = null; - if ($this->collProductI18ns instanceof PropelCollection) { + if ($this->collProductI18ns instanceof Collection) { $this->collProductI18ns->clearIterator(); } $this->collProductI18ns = null; - if ($this->collProductVersions instanceof PropelCollection) { + if ($this->collProductVersions instanceof Collection) { $this->collProductVersions->clearIterator(); } $this->collProductVersions = null; - if ($this->collCategorys instanceof PropelCollection) { - $this->collCategorys->clearIterator(); + if ($this->collCategories instanceof Collection) { + $this->collCategories->clearIterator(); } - $this->collCategorys = null; - if ($this->collProductsRelatedByAccessory instanceof PropelCollection) { + $this->collCategories = null; + if ($this->collProductsRelatedByAccessory instanceof Collection) { $this->collProductsRelatedByAccessory->clearIterator(); } $this->collProductsRelatedByAccessory = null; - if ($this->collProductsRelatedByProductId instanceof PropelCollection) { + if ($this->collProductsRelatedByProductId instanceof Collection) { $this->collProductsRelatedByProductId->clearIterator(); } $this->collProductsRelatedByProductId = null; @@ -6096,23 +6159,13 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(ProductTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -6120,11 +6173,11 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * 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) + * @return ChildProduct The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = ProductPeer::UPDATED_AT; + $this->modifiedColumns[] = ProductTableMap::UPDATED_AT; return $this; } @@ -6136,9 +6189,9 @@ abstract class BaseProduct extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Product The current object (for fluent API support) + * @return ChildProduct The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -6159,10 +6212,10 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return ProductI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildProductI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collProductI18ns) { @@ -6175,10 +6228,10 @@ abstract class BaseProduct extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new ProductI18n(); + $translation = new ChildProductI18n(); $translation->setLocale($locale); } else { - $translation = ProductI18nQuery::create() + $translation = ChildProductI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -6193,14 +6246,14 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Product The current object (for fluent API support) + * @return ChildProduct The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - ProductI18nQuery::create() + ChildProductI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -6220,10 +6273,10 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return ProductI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildProductI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -6232,7 +6285,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -6243,8 +6296,8 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -6256,7 +6309,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -6267,8 +6320,8 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -6280,7 +6333,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -6291,8 +6344,8 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -6304,7 +6357,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -6315,8 +6368,8 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -6329,7 +6382,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Enforce a new Version of this object upon next save. * - * @return Product + * @return \Thelia\Model\Product */ public function enforceVersioning() { @@ -6341,8 +6394,6 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * 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) @@ -6355,7 +6406,7 @@ abstract class BaseProduct extends BaseObject implements Persistent return true; } - if (ProductPeer::isVersioningEnabled() && ($this->isNew() || $this->isModified() || $this->isDeleted())) { + if (ChildProductQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) { return true; } @@ -6365,15 +6416,15 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Creates a version of the current object and saves it. * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return ProductVersion A version object + * @return ChildProductVersion A version object */ public function addVersion($con = null) { $this->enforceVersion = false; - $version = new ProductVersion(); + $version = new ChildProductVersion(); $version->setId($this->getId()); $version->setTaxRuleId($this->getTaxRuleId()); $version->setRef($this->getRef()); @@ -6398,19 +6449,18 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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 + * @param ConnectionInterface $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. + * @return ChildProduct The current object (for fluent API support) */ 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)); + throw new PropelException(sprintf('No ChildProduct object found with version %d', $version)); } $this->populateFromVersion($version, $con); @@ -6418,18 +6468,17 @@ abstract class BaseProduct extends BaseObject implements Persistent } /** - * Sets the properties of the curent object to the value they had at a specific version + * Sets the properties of the current 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. + * @param ChildProductVersion $version The version object to use + * @param ConnectionInterface $con the connection to use + * @param array $loadedObjects objects that been loaded in a chain of populateFromVersion calls on referrer or fk objects. * - * @return Product The current object (for fluent API support) + * @return ChildProduct The current object (for fluent API support) */ public function populateFromVersion($version, $con = null, &$loadedObjects = array()) { - - $loadedObjects['Product'][$version->getId()][$version->getVersion()] = $this; + $loadedObjects['ChildProduct'][$version->getId()][$version->getVersion()] = $this; $this->setId($version->getId()); $this->setTaxRuleId($version->getTaxRuleId()); $this->setRef($version->getRef()); @@ -6454,13 +6503,13 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Gets the latest persisted version number for the current object * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * * @return integer */ public function getLastVersionNumber($con = null) { - $v = ProductVersionQuery::create() + $v = ChildProductVersionQuery::create() ->filterByProduct($this) ->orderByVersion('desc') ->findOne($con); @@ -6474,9 +6523,9 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Checks whether the current object is the latest one * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return boolean + * @return Boolean */ public function isLastVersion($con = null) { @@ -6487,13 +6536,13 @@ abstract class BaseProduct extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con the connection to use * - * @return ProductVersion A version object + * @return ChildProductVersion A version object */ public function getOneVersion($versionNumber, $con = null) { - return ProductVersionQuery::create() + return ChildProductVersionQuery::create() ->filterByProduct($this) ->filterByVersion($versionNumber) ->findOne($con); @@ -6502,14 +6551,14 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Gets all the versions of this object, in incremental order * - * @param PropelPDO $con the connection to use + * @param ConnectionInterface $con the connection to use * - * @return PropelObjectCollection A list of ProductVersion objects + * @return ObjectCollection A list of ChildProductVersion objects */ public function getAllVersions($con = null) { $criteria = new Criteria(); - $criteria->addAscendingOrderByColumn(ProductVersionPeer::VERSION); + $criteria->addAscendingOrderByColumn(ProductVersionTableMap::VERSION); return $this->getProductVersions($criteria, $con); } @@ -6524,10 +6573,10 @@ abstract class BaseProduct extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $versionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -6549,11 +6598,11 @@ abstract class BaseProduct extends BaseObject implements Persistent * ); * * - * @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. + * @param integer $fromVersionNumber + * @param integer $toVersionNumber + * @param string $keys Main key used for the result diff (versions|columns) + * @param ConnectionInterface $con the connection to use + * @param array $ignoredColumns The columns to exclude from the diff. * * @return array A list of differences */ @@ -6568,7 +6617,7 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * Computes the diff between two versions. * - * print_r($this->computeDiff(1, 2)); + * print_r($book->computeDiff(1, 2)); * => array( * '1' => array('Title' => 'Book title at version 1'), * '2' => array('Title' => 'Book title at version 2') @@ -6617,18 +6666,133 @@ abstract class BaseProduct extends BaseObject implements Persistent /** * 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 + * @param Integer $number the number of record to return. + * @return PropelCollection|array \Thelia\Model\ProductVersion[] List of \Thelia\Model\ProductVersion objects */ - public function getLastVersions($number = 10, $criteria = null, PropelPDO $con = null) + public function getLastVersions($number = 10, $criteria = null, $con = null) { - $criteria = ProductVersionQuery::create(null, $criteria); - $criteria->addDescendingOrderByColumn(ProductVersionPeer::VERSION); + $criteria = ChildProductVersionQuery::create(null, $criteria); + $criteria->addDescendingOrderByColumn(ProductVersionTableMap::VERSION); $criteria->limit($number); return $this->getProductVersions($criteria, $con); } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/ProductCategory.php b/core/lib/Thelia/Model/Base/ProductCategory.php new file mode 100644 index 000000000..74affb0c0 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductCategory.php @@ -0,0 +1,1433 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProductCategory instance. If + * obj is an instance of ProductCategory, delegates to + * equals(ProductCategory). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProductCategory The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProductCategory The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 [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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [product_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProductCategory The current object (for fluent API support) + */ + public function setProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->product_id !== $v) { + $this->product_id = $v; + $this->modifiedColumns[] = ProductCategoryTableMap::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 \Thelia\Model\ProductCategory The current object (for fluent API support) + */ + public function setCategoryId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->category_id !== $v) { + $this->category_id = $v; + $this->modifiedColumns[] = ProductCategoryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ProductCategoryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ProductCategoryTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductCategoryTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductCategoryTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductCategoryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductCategoryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = ProductCategoryTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ProductCategory object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ProductCategoryTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProductCategoryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see ProductCategory::setDeleted() + * @see ProductCategory::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProductCategoryQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProductCategoryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProductCategoryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ProductCategoryTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProductCategoryTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; + } + if ($this->isColumnModified(ProductCategoryTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; + } + if ($this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ProductCategoryTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductCategoryTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ProductCategory'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ProductCategory'][serialize($this->getPrimaryKey())] = true; + $keys = ProductCategoryTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getProductId(), + $keys[1] => $this->getCategoryId(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductCategoryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ProductCategoryTableMap::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(ProductCategoryTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProductCategoryTableMap::PRODUCT_ID)) $criteria->add(ProductCategoryTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(ProductCategoryTableMap::CATEGORY_ID)) $criteria->add(ProductCategoryTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(ProductCategoryTableMap::CREATED_AT)) $criteria->add(ProductCategoryTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProductCategoryTableMap::UPDATED_AT)) $criteria->add(ProductCategoryTableMap::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(ProductCategoryTableMap::DATABASE_NAME); + $criteria->add(ProductCategoryTableMap::PRODUCT_ID, $this->product_id); + $criteria->add(ProductCategoryTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildProduct object. + * + * @param ChildProduct $v + * @return \Thelia\Model\ProductCategory The current object (for fluent API support) + * @throws PropelException + */ + public function setProduct(ChildProduct $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 ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addProductCategory($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProduct(ConnectionInterface $con = null) + { + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::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->addProductCategories($this); + */ + } + + return $this->aProduct; + } + + /** + * Declares an association between this object and a ChildCategory object. + * + * @param ChildCategory $v + * @return \Thelia\Model\ProductCategory The current object (for fluent API support) + * @throws PropelException + */ + public function setCategory(ChildCategory $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 ChildCategory object, it will not be re-added. + if ($v !== null) { + $v->addProductCategory($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCategory object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. + * @throws PropelException + */ + public function getCategory(ConnectionInterface $con = null) + { + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::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->addProductCategories($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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProduct = null; + $this->aCategory = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProductCategoryTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildProductCategory The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProductCategoryTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php b/core/lib/Thelia/Model/Base/ProductCategoryQuery.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseProductCategoryQuery.php rename to core/lib/Thelia/Model/Base/ProductCategoryQuery.php index 30a1d64d7..fd40e93c7 --- a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php +++ b/core/lib/Thelia/Model/Base/ProductCategoryQuery.php @@ -1,93 +1,91 @@ setModelAlias($modelAlias); } @@ -107,23 +105,22 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * $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 + * @param array[$product_id, $category_id] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ProductCategory|ProductCategory[]|mixed the result, formatted by the current formatter + * @return ChildProductCategory|array|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 + if ((null !== ($obj = ProductCategoryTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ProductCategoryTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -140,14 +137,13 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ProductCategory A model object, or null if the key is not found - * @throws PropelException + * @return ChildProductCategory A model object, or null if the key is not found */ 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'; + $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); @@ -155,13 +151,13 @@ abstract class BaseProductCategoryQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ProductCategory(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProductCategory(); $obj->hydrate($row); - ProductCategoryPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ProductCategoryTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -172,19 +168,19 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ProductCategory|ProductCategory[]|mixed the result, formatted by the current formatter + * @return ChildProductCategory|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -193,22 +189,22 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ProductCategory[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -216,12 +212,12 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ProductCategoryQuery The current query, for fluid interface + * @return ChildProductCategoryQuery 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); + $this->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $key[1], Criteria::EQUAL); return $this; } @@ -231,7 +227,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ProductCategoryQuery The current query, for fluid interface + * @return ChildProductCategoryQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -239,8 +235,8 @@ abstract class BaseProductCategoryQuery extends ModelCriteria 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 = $this->getNewCriterion(ProductCategoryTableMap::PRODUCT_ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ProductCategoryTableMap::CATEGORY_ID, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -255,8 +251,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * * $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 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 * * * @see filterByProduct() @@ -267,18 +262,18 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * 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 + * @return ChildProductCategoryQuery 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); + $this->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($productId['max'])) { - $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -289,7 +284,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId, $comparison); + return $this->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $productId, $comparison); } /** @@ -299,8 +294,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * * $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 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 * * * @see filterByCategory() @@ -311,18 +305,18 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * 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 + * @return ChildProductCategoryQuery 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); + $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($categoryId['max'])) { - $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -333,7 +327,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $categoryId, $comparison); } /** @@ -354,18 +348,18 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * 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 + * @return ChildProductCategoryQuery 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); + $this->addUsingAlias(ProductCategoryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductCategoryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -376,7 +370,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ProductCategoryTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -397,18 +391,18 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * 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 + * @return ChildProductCategoryQuery 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); + $this->addUsingAlias(ProductCategoryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductCategoryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -419,32 +413,31 @@ abstract class BaseProductCategoryQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ProductCategoryTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildProductCategoryQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ProductCategoryTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -454,7 +447,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * @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 + * @return ChildProductCategoryQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -483,7 +476,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -499,28 +492,27 @@ abstract class BaseProductCategoryQuery extends ModelCriteria } /** - * Filter the query by a related Category object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Category|ObjectCollection $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. + * @return ChildProductCategoryQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = null) { - if ($category instanceof Category) { + if ($category instanceof \Thelia\Model\Category) { return $this - ->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { + ->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ProductCategoryTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); } } @@ -530,7 +522,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * @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 + * @return ChildProductCategoryQuery The current query, for fluid interface */ public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -559,7 +551,7 @@ abstract class BaseProductCategoryQuery extends ModelCriteria /** * Use the Category relation Category object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -577,21 +569,96 @@ abstract class BaseProductCategoryQuery extends ModelCriteria /** * Exclude object from result * - * @param ProductCategory $productCategory Object to remove from the list of results + * @param ChildProductCategory $productCategory Object to remove from the list of results * - * @return ProductCategoryQuery The current query, for fluid interface + * @return ChildProductCategoryQuery 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->addCond('pruneCond0', $this->getAliasedColName(ProductCategoryTableMap::PRODUCT_ID), $productCategory->getProductId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ProductCategoryTableMap::CATEGORY_ID), $productCategory->getCategoryId(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } + /** + * Deletes all rows from the product_category table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProductCategoryTableMap::clearInstancePool(); + ProductCategoryTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProductCategory or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProductCategory object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProductCategoryTableMap::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(); + + + ProductCategoryTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProductCategoryTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -599,31 +666,11 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ProductCategoryQuery The current query, for fluid interface + * @return ChildProductCategoryQuery 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); + return $this->addUsingAlias(ProductCategoryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -631,30 +678,51 @@ abstract class BaseProductCategoryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ProductCategoryQuery The current query, for fluid interface + * @return ChildProductCategoryQuery 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); + return $this->addUsingAlias(ProductCategoryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildProductCategoryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProductCategoryTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildProductCategoryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProductCategoryTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ProductCategoryQuery The current query, for fluid interface + * @return ChildProductCategoryQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(ProductCategoryPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(ProductCategoryTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ProductCategoryQuery The current query, for fluid interface + * @return ChildProductCategoryQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(ProductCategoryPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(ProductCategoryTableMap::CREATED_AT); } -} + +} // ProductCategoryQuery diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php new file mode 100644 index 000000000..7b6e65976 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProductI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ProductI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProductI18n instance. If + * obj is an instance of ProductI18n, delegates to + * equals(ProductI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProductI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProductI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ProductI18nTableMap::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 \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ProductI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ProductI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ProductI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ProductI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ProductI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ProductI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ProductI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ProductI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProductI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProduct = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ProductI18n::setDeleted() + * @see ProductI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProductI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME); + } + + $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); + ProductI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProductI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ProductI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ProductI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ProductI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ProductI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ProductI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ProductI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ProductI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ProductI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProductI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ProductI18nTableMap::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(ProductI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProductI18nTableMap::ID)) $criteria->add(ProductI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ProductI18nTableMap::LOCALE)) $criteria->add(ProductI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ProductI18nTableMap::TITLE)) $criteria->add(ProductI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ProductI18nTableMap::DESCRIPTION)) $criteria->add(ProductI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ProductI18nTableMap::CHAPO)) $criteria->add(ProductI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ProductI18nTableMap::POSTSCRIPTUM)) $criteria->add(ProductI18nTableMap::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(ProductI18nTableMap::DATABASE_NAME); + $criteria->add(ProductI18nTableMap::ID, $this->id); + $criteria->add(ProductI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildProduct object. + * + * @param ChildProduct $v + * @return \Thelia\Model\ProductI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setProduct(ChildProduct $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 ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addProductI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProduct(ConnectionInterface $con = null) + { + if ($this->aProduct === null && ($this->id !== null)) { + $this->aProduct = ChildProductQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProduct = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProductI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseProductI18nQuery.php b/core/lib/Thelia/Model/Base/ProductI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseProductI18nQuery.php rename to core/lib/Thelia/Model/Base/ProductI18nQuery.php index 02dc6e1fd..d64c95892 --- a/core/lib/Thelia/Model/om/BaseProductI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ProductI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseProductI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ProductI18n|ProductI18n[]|mixed the result, formatted by the current formatter + * @return ChildProductI18n|array|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 + if ((null !== ($obj = ProductI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ProductI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseProductI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ProductI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildProductI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `product_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseProductI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ProductI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProductI18n(); $obj->hydrate($row); - ProductI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ProductI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseProductI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ProductI18n|ProductI18n[]|mixed the result, formatted by the current formatter + * @return ChildProductI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseProductI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ProductI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseProductI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ProductI18nQuery The current query, for fluid interface + * @return ChildProductI18nQuery 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); + $this->addUsingAlias(ProductI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ProductI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ProductI18nQuery The current query, for fluid interface + * @return ChildProductI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseProductI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(ProductI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ProductI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByProduct() @@ -270,18 +266,18 @@ abstract class BaseProductI18nQuery extends ModelCriteria * 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 + * @return ChildProductI18nQuery 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); + $this->addUsingAlias(ProductI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ProductI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(ProductI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria * 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 + * @return ChildProductI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(ProductI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria * 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 + * @return ChildProductI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(ProductI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria * 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 + * @return ChildProductI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(ProductI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria * 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 + * @return ChildProductI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(ProductI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria * 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 + * @return ChildProductI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseProductI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(ProductI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildProductI18nQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(ProductI18nPeer::ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(ProductI18nTableMap::ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ProductI18nPeer::ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ProductI18nTableMap::ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria * @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 + * @return ChildProductI18nQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseProductI18nQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseProductI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param ProductI18n $productI18n Object to remove from the list of results + * @param ChildProductI18n $productI18n Object to remove from the list of results * - * @return ProductI18nQuery The current query, for fluid interface + * @return ChildProductI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(ProductI18nTableMap::ID), $productI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ProductI18nTableMap::LOCALE), $productI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the product_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProductI18nTableMap::clearInstancePool(); + ProductI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProductI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProductI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProductI18nTableMap::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(); + + + ProductI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProductI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ProductI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php old mode 100755 new mode 100644 similarity index 60% rename from core/lib/Thelia/Model/om/BaseProductQuery.php rename to core/lib/Thelia/Model/Base/ProductQuery.php index 90ccbf69b..c4f2ce371 --- a/core/lib/Thelia/Model/om/BaseProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -1,194 +1,191 @@ setModelAlias($modelAlias); } @@ -209,21 +206,21 @@ abstract class BaseProductQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Product|Product[]|mixed the result, formatted by the current formatter + * @return ChildProduct|array|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 + if ((null !== ($obj = ProductTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ProductTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -235,46 +232,31 @@ abstract class BaseProductQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Product A model object, or null if the key is not found - * @throws PropelException + * @return ChildProduct A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Product(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProduct(); $obj->hydrate($row); - ProductPeer::addInstanceToPool($obj, (string) $key); + ProductTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -285,19 +267,19 @@ abstract class BaseProductQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Product|Product[]|mixed the result, formatted by the current formatter + * @return ChildProduct|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -306,22 +288,22 @@ abstract class BaseProductQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Product[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -329,12 +311,12 @@ abstract class BaseProductQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ProductQuery The current query, for fluid interface + * @return ChildProductQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(ProductPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(ProductTableMap::ID, $key, Criteria::EQUAL); } /** @@ -342,12 +324,12 @@ abstract class BaseProductQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ProductQuery The current query, for fluid interface + * @return ChildProductQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(ProductPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(ProductTableMap::ID, $keys, Criteria::IN); } /** @@ -357,8 +339,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -367,18 +348,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ProductPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -389,7 +370,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::ID, $id, $comparison); + return $this->addUsingAlias(ProductTableMap::ID, $id, $comparison); } /** @@ -399,8 +380,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12 * * * @see filterByTaxRule() @@ -411,18 +391,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::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); + $this->addUsingAlias(ProductTableMap::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -433,7 +413,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRuleId, $comparison); + return $this->addUsingAlias(ProductTableMap::TAX_RULE_ID, $taxRuleId, $comparison); } /** @@ -449,7 +429,7 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery The current query, for fluid interface */ public function filterByRef($ref = null, $comparison = null) { @@ -462,7 +442,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::REF, $ref, $comparison); + return $this->addUsingAlias(ProductTableMap::REF, $ref, $comparison); } /** @@ -472,8 +452,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByPrice(array('min' => 12)); // WHERE price > 12 * * * @param mixed $price The value to use as filter. @@ -482,18 +461,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($price['max'])) { - $this->addUsingAlias(ProductPeer::PRICE, $price['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -504,7 +483,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::PRICE, $price, $comparison); + return $this->addUsingAlias(ProductTableMap::PRICE, $price, $comparison); } /** @@ -514,8 +493,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByPrice2(array('min' => 12)); // WHERE price2 > 12 * * * @param mixed $price2 The value to use as filter. @@ -524,18 +502,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::PRICE2, $price2['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($price2['max'])) { - $this->addUsingAlias(ProductPeer::PRICE2, $price2['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::PRICE2, $price2['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -546,7 +524,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::PRICE2, $price2, $comparison); + return $this->addUsingAlias(ProductTableMap::PRICE2, $price2, $comparison); } /** @@ -556,8 +534,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax > 12 * * * @param mixed $ecotax The value to use as filter. @@ -566,18 +543,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::ECOTAX, $ecotax['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($ecotax['max'])) { - $this->addUsingAlias(ProductPeer::ECOTAX, $ecotax['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::ECOTAX, $ecotax['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -588,7 +565,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::ECOTAX, $ecotax, $comparison); + return $this->addUsingAlias(ProductTableMap::ECOTAX, $ecotax, $comparison); } /** @@ -598,8 +575,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByNewness(array('min' => 12)); // WHERE newness > 12 * * * @param mixed $newness The value to use as filter. @@ -608,18 +584,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($newness['max'])) { - $this->addUsingAlias(ProductPeer::NEWNESS, $newness['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::NEWNESS, $newness['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -630,7 +606,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::NEWNESS, $newness, $comparison); + return $this->addUsingAlias(ProductTableMap::NEWNESS, $newness, $comparison); } /** @@ -640,8 +616,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByPromo(array('min' => 12)); // WHERE promo > 12 * * * @param mixed $promo The value to use as filter. @@ -650,18 +625,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::PROMO, $promo['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($promo['max'])) { - $this->addUsingAlias(ProductPeer::PROMO, $promo['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::PROMO, $promo['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -672,7 +647,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::PROMO, $promo, $comparison); + return $this->addUsingAlias(ProductTableMap::PROMO, $promo, $comparison); } /** @@ -682,8 +657,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12 * * * @param mixed $quantity The value to use as filter. @@ -692,18 +666,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($quantity['max'])) { - $this->addUsingAlias(ProductPeer::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -714,7 +688,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::QUANTITY, $quantity, $comparison); + return $this->addUsingAlias(ProductTableMap::QUANTITY, $quantity, $comparison); } /** @@ -724,8 +698,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 * * * @param mixed $visible The value to use as filter. @@ -734,18 +707,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($visible['max'])) { - $this->addUsingAlias(ProductPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -756,7 +729,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::VISIBLE, $visible, $comparison); + return $this->addUsingAlias(ProductTableMap::VISIBLE, $visible, $comparison); } /** @@ -766,8 +739,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12 * * * @param mixed $weight The value to use as filter. @@ -776,18 +748,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($weight['max'])) { - $this->addUsingAlias(ProductPeer::WEIGHT, $weight['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::WEIGHT, $weight['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -798,7 +770,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::WEIGHT, $weight, $comparison); + return $this->addUsingAlias(ProductTableMap::WEIGHT, $weight, $comparison); } /** @@ -808,8 +780,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -818,18 +789,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(ProductPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -840,7 +811,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(ProductTableMap::POSITION, $position, $comparison); } /** @@ -861,18 +832,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ProductPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -883,7 +854,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ProductTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -904,18 +875,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ProductPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -926,7 +897,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ProductTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -936,8 +907,7 @@ abstract class BaseProductQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -946,18 +916,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(ProductPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -968,7 +938,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::VERSION, $version, $comparison); + return $this->addUsingAlias(ProductTableMap::VERSION, $version, $comparison); } /** @@ -989,18 +959,18 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery 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); + $this->addUsingAlias(ProductTableMap::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); + $this->addUsingAlias(ProductTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -1011,7 +981,7 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(ProductTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -1027,7 +997,7 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @return ChildProductQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -1040,32 +1010,31 @@ abstract class BaseProductQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(ProductTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related TaxRule object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\TaxRule|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByTaxRule($taxRule, $comparison = null) { - if ($taxRule instanceof TaxRule) { + if ($taxRule instanceof \Thelia\Model\TaxRule) { return $this - ->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRule->getId(), $comparison); - } elseif ($taxRule instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::TAX_RULE_ID, $taxRule->getId(), $comparison); + } elseif ($taxRule instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ProductTableMap::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection'); + throw new PropelException('filterByTaxRule() only accepts arguments of type \Thelia\Model\TaxRule or Collection'); } } @@ -1075,7 +1044,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1104,7 +1073,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the TaxRule relation TaxRule object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1120,26 +1089,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related ProductCategory object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ProductCategory|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByProductCategory($productCategory, $comparison = null) { - if ($productCategory instanceof ProductCategory) { + if ($productCategory instanceof \Thelia\Model\ProductCategory) { return $this - ->addUsingAlias(ProductPeer::ID, $productCategory->getProductId(), $comparison); - } elseif ($productCategory instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $productCategory->getProductId(), $comparison); + } elseif ($productCategory instanceof ObjectCollection) { return $this ->useProductCategoryQuery() ->filterByPrimaryKeys($productCategory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection'); + throw new PropelException('filterByProductCategory() only accepts arguments of type \Thelia\Model\ProductCategory or Collection'); } } @@ -1149,7 +1117,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1178,7 +1146,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the ProductCategory relation ProductCategory object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1194,26 +1162,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related FeatureProd object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\FeatureProd|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByFeatureProd($featureProd, $comparison = null) { - if ($featureProd instanceof FeatureProd) { + if ($featureProd instanceof \Thelia\Model\FeatureProd) { return $this - ->addUsingAlias(ProductPeer::ID, $featureProd->getProductId(), $comparison); - } elseif ($featureProd instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $featureProd->getProductId(), $comparison); + } elseif ($featureProd instanceof ObjectCollection) { return $this ->useFeatureProdQuery() ->filterByPrimaryKeys($featureProd->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection'); + throw new PropelException('filterByFeatureProd() only accepts arguments of type \Thelia\Model\FeatureProd or Collection'); } } @@ -1223,7 +1190,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1252,7 +1219,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the FeatureProd relation FeatureProd object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1268,26 +1235,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related Stock object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Stock|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByStock($stock, $comparison = null) { - if ($stock instanceof Stock) { + if ($stock instanceof \Thelia\Model\Stock) { return $this - ->addUsingAlias(ProductPeer::ID, $stock->getProductId(), $comparison); - } elseif ($stock instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $stock->getProductId(), $comparison); + } elseif ($stock instanceof ObjectCollection) { return $this ->useStockQuery() ->filterByPrimaryKeys($stock->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection'); + throw new PropelException('filterByStock() only accepts arguments of type \Thelia\Model\Stock or Collection'); } } @@ -1297,7 +1263,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1326,7 +1292,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the Stock relation Stock object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1342,26 +1308,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related ContentAssoc object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ContentAssoc|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByContentAssoc($contentAssoc, $comparison = null) { - if ($contentAssoc instanceof ContentAssoc) { + if ($contentAssoc instanceof \Thelia\Model\ContentAssoc) { return $this - ->addUsingAlias(ProductPeer::ID, $contentAssoc->getProductId(), $comparison); - } elseif ($contentAssoc instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $contentAssoc->getProductId(), $comparison); + } elseif ($contentAssoc instanceof ObjectCollection) { return $this ->useContentAssocQuery() ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); + throw new PropelException('filterByContentAssoc() only accepts arguments of type \Thelia\Model\ContentAssoc or Collection'); } } @@ -1371,7 +1336,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1400,7 +1365,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the ContentAssoc relation ContentAssoc object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1416,26 +1381,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related Image object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Image|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByImage($image, $comparison = null) { - if ($image instanceof Image) { + if ($image instanceof \Thelia\Model\Image) { return $this - ->addUsingAlias(ProductPeer::ID, $image->getProductId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $image->getProductId(), $comparison); + } elseif ($image instanceof ObjectCollection) { return $this ->useImageQuery() ->filterByPrimaryKeys($image->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); + throw new PropelException('filterByImage() only accepts arguments of type \Thelia\Model\Image or Collection'); } } @@ -1445,7 +1409,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1474,7 +1438,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the Image relation Image object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1490,26 +1454,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related Document object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Document|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByDocument($document, $comparison = null) { - if ($document instanceof Document) { + if ($document instanceof \Thelia\Model\Document) { return $this - ->addUsingAlias(ProductPeer::ID, $document->getProductId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $document->getProductId(), $comparison); + } elseif ($document instanceof ObjectCollection) { return $this ->useDocumentQuery() ->filterByPrimaryKeys($document->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); + throw new PropelException('filterByDocument() only accepts arguments of type \Thelia\Model\Document or Collection'); } } @@ -1519,7 +1482,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1548,7 +1511,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the Document relation Document object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1564,26 +1527,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related Accessory object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Accessory|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByAccessoryRelatedByProductId($accessory, $comparison = null) { - if ($accessory instanceof Accessory) { + if ($accessory instanceof \Thelia\Model\Accessory) { return $this - ->addUsingAlias(ProductPeer::ID, $accessory->getProductId(), $comparison); - } elseif ($accessory instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $accessory->getProductId(), $comparison); + } elseif ($accessory instanceof ObjectCollection) { return $this ->useAccessoryRelatedByProductIdQuery() ->filterByPrimaryKeys($accessory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAccessoryRelatedByProductId() only accepts arguments of type Accessory or PropelCollection'); + throw new PropelException('filterByAccessoryRelatedByProductId() only accepts arguments of type \Thelia\Model\Accessory or Collection'); } } @@ -1593,7 +1555,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinAccessoryRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1622,7 +1584,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the AccessoryRelatedByProductId relation Accessory object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1638,26 +1600,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related Accessory object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Accessory|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByAccessoryRelatedByAccessory($accessory, $comparison = null) { - if ($accessory instanceof Accessory) { + if ($accessory instanceof \Thelia\Model\Accessory) { return $this - ->addUsingAlias(ProductPeer::ID, $accessory->getAccessory(), $comparison); - } elseif ($accessory instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $accessory->getAccessory(), $comparison); + } elseif ($accessory instanceof ObjectCollection) { return $this ->useAccessoryRelatedByAccessoryQuery() ->filterByPrimaryKeys($accessory->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAccessoryRelatedByAccessory() only accepts arguments of type Accessory or PropelCollection'); + throw new PropelException('filterByAccessoryRelatedByAccessory() only accepts arguments of type \Thelia\Model\Accessory or Collection'); } } @@ -1667,7 +1628,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinAccessoryRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1696,7 +1657,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the AccessoryRelatedByAccessory relation Accessory object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1712,26 +1673,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related Rewriting object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Rewriting|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByRewriting($rewriting, $comparison = null) { - if ($rewriting instanceof Rewriting) { + if ($rewriting instanceof \Thelia\Model\Rewriting) { return $this - ->addUsingAlias(ProductPeer::ID, $rewriting->getProductId(), $comparison); - } elseif ($rewriting instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $rewriting->getProductId(), $comparison); + } elseif ($rewriting instanceof ObjectCollection) { return $this ->useRewritingQuery() ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection'); + throw new PropelException('filterByRewriting() only accepts arguments of type \Thelia\Model\Rewriting or Collection'); } } @@ -1741,7 +1701,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -1770,7 +1730,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the Rewriting relation Rewriting object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1786,26 +1746,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related ProductI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ProductI18n|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByProductI18n($productI18n, $comparison = null) { - if ($productI18n instanceof ProductI18n) { + if ($productI18n instanceof \Thelia\Model\ProductI18n) { return $this - ->addUsingAlias(ProductPeer::ID, $productI18n->getId(), $comparison); - } elseif ($productI18n instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $productI18n->getId(), $comparison); + } elseif ($productI18n instanceof ObjectCollection) { return $this ->useProductI18nQuery() ->filterByPrimaryKeys($productI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByProductI18n() only accepts arguments of type ProductI18n or PropelCollection'); + throw new PropelException('filterByProductI18n() only accepts arguments of type \Thelia\Model\ProductI18n or Collection'); } } @@ -1815,7 +1774,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinProductI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -1844,7 +1803,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the ProductI18n relation ProductI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1860,26 +1819,25 @@ abstract class BaseProductQuery extends ModelCriteria } /** - * Filter the query by a related ProductVersion object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ProductVersion|ObjectCollection $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. + * @return ChildProductQuery The current query, for fluid interface */ public function filterByProductVersion($productVersion, $comparison = null) { - if ($productVersion instanceof ProductVersion) { + if ($productVersion instanceof \Thelia\Model\ProductVersion) { return $this - ->addUsingAlias(ProductPeer::ID, $productVersion->getId(), $comparison); - } elseif ($productVersion instanceof PropelObjectCollection) { + ->addUsingAlias(ProductTableMap::ID, $productVersion->getId(), $comparison); + } elseif ($productVersion instanceof ObjectCollection) { return $this ->useProductVersionQuery() ->filterByPrimaryKeys($productVersion->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByProductVersion() only accepts arguments of type ProductVersion or PropelCollection'); + throw new PropelException('filterByProductVersion() only accepts arguments of type \Thelia\Model\ProductVersion or Collection'); } } @@ -1889,7 +1847,7 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function joinProductVersion($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1918,7 +1876,7 @@ abstract class BaseProductQuery extends ModelCriteria /** * Use the ProductVersion relation ProductVersion object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1937,10 +1895,10 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = Criteria::EQUAL) { @@ -1954,10 +1912,10 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function filterByProductRelatedByAccessory($product, $comparison = Criteria::EQUAL) { @@ -1971,10 +1929,10 @@ abstract class BaseProductQuery extends ModelCriteria * 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 + * @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 + * @return ChildProductQuery The current query, for fluid interface */ public function filterByProductRelatedByProductId($product, $comparison = Criteria::EQUAL) { @@ -1987,19 +1945,94 @@ abstract class BaseProductQuery extends ModelCriteria /** * Exclude object from result * - * @param Product $product Object to remove from the list of results + * @param ChildProduct $product Object to remove from the list of results * - * @return ProductQuery The current query, for fluid interface + * @return ChildProductQuery The current query, for fluid interface */ public function prune($product = null) { if ($product) { - $this->addUsingAlias(ProductPeer::ID, $product->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(ProductTableMap::ID, $product->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the product table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProductTableMap::clearInstancePool(); + ProductTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProduct or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProduct object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProductTableMap::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(); + + + ProductTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProductTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -2007,31 +2040,11 @@ abstract class BaseProductQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ProductQuery The current query, for fluid interface + * @return ChildProductQuery 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); + return $this->addUsingAlias(ProductTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -2039,32 +2052,53 @@ abstract class BaseProductQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ProductQuery The current query, for fluid interface + * @return ChildProductQuery 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); + return $this->addUsingAlias(ProductTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildProductQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProductTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildProductQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProductTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ProductQuery The current query, for fluid interface + * @return ChildProductQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(ProductPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(ProductTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ProductQuery The current query, for fluid interface + * @return ChildProductQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(ProductPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(ProductTableMap::CREATED_AT); } + // i18n behavior /** @@ -2074,9 +2108,9 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ProductI18n'; @@ -2092,9 +2126,9 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -2113,13 +2147,41 @@ abstract class BaseProductQuery extends ModelCriteria * @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 + * @return ChildProductI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ProductI18n', 'Thelia\Model\ProductI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'ProductI18n', '\Thelia\Model\ProductI18nQuery'); } -} + // versionable behavior + + /** + * Checks whether versioning is enabled + * + * @return boolean + */ + static public function isVersioningEnabled() + { + return self::$isVersioningEnabled; + } + + /** + * Enables versioning + */ + static public function enableVersioning() + { + self::$isVersioningEnabled = true; + } + + /** + * Disables versioning + */ + static public function disableVersioning() + { + self::$isVersioningEnabled = false; + } + +} // ProductQuery diff --git a/core/lib/Thelia/Model/om/BaseProductVersion.php b/core/lib/Thelia/Model/Base/ProductVersion.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseProductVersion.php rename to core/lib/Thelia/Model/Base/ProductVersion.php index 341966473..4351460a5 --- a/core/lib/Thelia/Model/om/BaseProductVersion.php +++ b/core/lib/Thelia/Model/Base/ProductVersion.php @@ -1,51 +1,59 @@ applyDefaultValues(); } + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProductVersion instance. If + * obj is an instance of ProductVersion, delegates to + * equals(ProductVersion). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProductVersion The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProductVersion The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [tax_rule_id] column value. * - * @return int + * @return int */ public function getTaxRuleId() { + return $this->tax_rule_id; } /** * Get the [ref] column value. * - * @return string + * @return string */ public function getRef() { + return $this->ref; } /** * Get the [price] column value. * - * @return double + * @return double */ public function getPrice() { + return $this->price; } /** * Get the [price2] column value. * - * @return double + * @return double */ public function getPrice2() { + return $this->price2; } /** * Get the [ecotax] column value. * - * @return double + * @return double */ public function getEcotax() { + return $this->ecotax; } /** * Get the [newness] column value. * - * @return int + * @return int */ public function getNewness() { + return $this->newness; } /** * Get the [promo] column value. * - * @return int + * @return int */ public function getPromo() { + return $this->promo; } /** * Get the [quantity] column value. * - * @return int + * @return int */ public function getQuantity() { + return $this->quantity; } /** * Get the [visible] column value. * - * @return int + * @return int */ public function getVisible() { + return $this->visible; } /** * Get the [weight] column value. * - * @return double + * @return double */ public function getWeight() { + return $this->weight; } /** * Get the [position] column value. * - * @return int + * @return int */ public function getPosition() { + return $this->position; } @@ -328,89 +582,50 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version] column value. * - * @return int + * @return int */ public function getVersion() { + return $this->version; } @@ -418,67 +633,48 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getVersionCreatedAt($format = NULL) { - 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; + return $this->version_created_at; + } else { + return $this->version_created_at !== null ? $this->version_created_at->format($format) : null; } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - } /** * Get the [version_created_by] column value. * - * @return string + * @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) + * @param int $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = ProductVersionPeer::ID; + $this->modifiedColumns[] = ProductVersionTableMap::ID; } if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { @@ -492,18 +688,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [tax_rule_id] column. * - * @param int $v new value - * @return ProductVersion The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setTaxRuleId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->tax_rule_id !== $v) { $this->tax_rule_id = $v; - $this->modifiedColumns[] = ProductVersionPeer::TAX_RULE_ID; + $this->modifiedColumns[] = ProductVersionTableMap::TAX_RULE_ID; } @@ -513,18 +709,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [ref] column. * - * @param string $v new value - * @return ProductVersion The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setRef($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->ref !== $v) { $this->ref = $v; - $this->modifiedColumns[] = ProductVersionPeer::REF; + $this->modifiedColumns[] = ProductVersionTableMap::REF; } @@ -534,18 +730,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [price] column. * - * @param double $v new value - * @return ProductVersion The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setPrice($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->price !== $v) { $this->price = $v; - $this->modifiedColumns[] = ProductVersionPeer::PRICE; + $this->modifiedColumns[] = ProductVersionTableMap::PRICE; } @@ -555,18 +751,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [price2] column. * - * @param double $v new value - * @return ProductVersion The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setPrice2($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->price2 !== $v) { $this->price2 = $v; - $this->modifiedColumns[] = ProductVersionPeer::PRICE2; + $this->modifiedColumns[] = ProductVersionTableMap::PRICE2; } @@ -576,18 +772,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [ecotax] column. * - * @param double $v new value - * @return ProductVersion The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setEcotax($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->ecotax !== $v) { $this->ecotax = $v; - $this->modifiedColumns[] = ProductVersionPeer::ECOTAX; + $this->modifiedColumns[] = ProductVersionTableMap::ECOTAX; } @@ -597,18 +793,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [newness] column. * - * @param int $v new value - * @return ProductVersion The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setNewness($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->newness !== $v) { $this->newness = $v; - $this->modifiedColumns[] = ProductVersionPeer::NEWNESS; + $this->modifiedColumns[] = ProductVersionTableMap::NEWNESS; } @@ -618,18 +814,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [promo] column. * - * @param int $v new value - * @return ProductVersion The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setPromo($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->promo !== $v) { $this->promo = $v; - $this->modifiedColumns[] = ProductVersionPeer::PROMO; + $this->modifiedColumns[] = ProductVersionTableMap::PROMO; } @@ -639,18 +835,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [quantity] column. * - * @param int $v new value - * @return ProductVersion The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setQuantity($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->quantity !== $v) { $this->quantity = $v; - $this->modifiedColumns[] = ProductVersionPeer::QUANTITY; + $this->modifiedColumns[] = ProductVersionTableMap::QUANTITY; } @@ -660,18 +856,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [visible] column. * - * @param int $v new value - * @return ProductVersion The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setVisible($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->visible !== $v) { $this->visible = $v; - $this->modifiedColumns[] = ProductVersionPeer::VISIBLE; + $this->modifiedColumns[] = ProductVersionTableMap::VISIBLE; } @@ -681,18 +877,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [weight] column. * - * @param double $v new value - * @return ProductVersion The current object (for fluent API support) + * @param double $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setWeight($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (double) $v; } if ($this->weight !== $v) { $this->weight = $v; - $this->modifiedColumns[] = ProductVersionPeer::WEIGHT; + $this->modifiedColumns[] = ProductVersionTableMap::WEIGHT; } @@ -702,18 +898,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [position] column. * - * @param int $v new value - * @return ProductVersion The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setPosition($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->position !== $v) { $this->position = $v; - $this->modifiedColumns[] = ProductVersionPeer::POSITION; + $this->modifiedColumns[] = ProductVersionTableMap::POSITION; } @@ -723,19 +919,17 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ProductVersionTableMap::CREATED_AT; } } // if either are not null @@ -746,19 +940,17 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ProductVersionTableMap::UPDATED_AT; } } // if either are not null @@ -769,18 +961,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [version] column. * - * @param int $v new value - * @return ProductVersion The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setVersion($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->version !== $v) { $this->version = $v; - $this->modifiedColumns[] = ProductVersionPeer::VERSION; + $this->modifiedColumns[] = ProductVersionTableMap::VERSION; } @@ -790,19 +982,17 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setVersionCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->version_created_at) { + $this->version_created_at = $dt; + $this->modifiedColumns[] = ProductVersionTableMap::VERSION_CREATED_AT; } } // if either are not null @@ -813,18 +1003,18 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the value of [version_created_by] column. * - * @param string $v new value - * @return ProductVersion The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) */ public function setVersionCreatedBy($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->version_created_by !== $v) { $this->version_created_by = $v; - $this->modifiedColumns[] = ProductVersionPeer::VERSION_CREATED_BY; + $this->modifiedColumns[] = ProductVersionTableMap::VERSION_CREATED_BY; } @@ -861,7 +1051,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent return false; } - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -873,33 +1063,80 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProductVersionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductVersionTableMap::translateFieldName('TaxRuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_rule_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductVersionTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ref = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductVersionTableMap::translateFieldName('Price', TableMap::TYPE_PHPNAME, $indexType)]; + $this->price = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductVersionTableMap::translateFieldName('Price2', TableMap::TYPE_PHPNAME, $indexType)]; + $this->price2 = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductVersionTableMap::translateFieldName('Ecotax', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ecotax = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductVersionTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)]; + $this->newness = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductVersionTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->promo = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductVersionTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)]; + $this->quantity = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductVersionTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; + $this->visible = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductVersionTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; + $this->weight = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : ProductVersionTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : ProductVersionTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : ProductVersionTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : ProductVersionTableMap::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->version_created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : ProductVersionTableMap::translateFieldName('VersionCreatedBy', TableMap::TYPE_PHPNAME, $indexType)]; + $this->version_created_by = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); @@ -907,11 +1144,11 @@ abstract class BaseProductVersion extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 17; // 17 = ProductVersionPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 17; // 17 = ProductVersionTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating ProductVersion object", $e); + throw new PropelException("Error populating \Thelia\Model\ProductVersion object", 0, $e); } } @@ -930,7 +1167,6 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aProduct !== null && $this->id !== $this->aProduct->getId()) { $this->aProduct = null; } @@ -941,12 +1177,12 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -957,19 +1193,19 @@ abstract class BaseProductVersion extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ProductVersionTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildProductVersionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -980,26 +1216,25 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see ProductVersion::setDeleted() + * @see ProductVersion::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ProductVersionQuery::create() + $deleteQuery = ChildProductVersionQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -1024,20 +1259,19 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -1057,7 +1291,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - ProductVersionPeer::addInstanceToPool($this); + ProductVersionTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1076,19 +1310,19 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -1120,72 +1354,72 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $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(ProductVersionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ProductVersionPeer::TAX_RULE_ID)) { - $modifiedColumns[':p' . $index++] = '`tax_rule_id`'; + if ($this->isColumnModified(ProductVersionTableMap::TAX_RULE_ID)) { + $modifiedColumns[':p' . $index++] = 'TAX_RULE_ID'; } - if ($this->isColumnModified(ProductVersionPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; + if ($this->isColumnModified(ProductVersionTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; } - if ($this->isColumnModified(ProductVersionPeer::PRICE)) { - $modifiedColumns[':p' . $index++] = '`price`'; + if ($this->isColumnModified(ProductVersionTableMap::PRICE)) { + $modifiedColumns[':p' . $index++] = 'PRICE'; } - if ($this->isColumnModified(ProductVersionPeer::PRICE2)) { - $modifiedColumns[':p' . $index++] = '`price2`'; + if ($this->isColumnModified(ProductVersionTableMap::PRICE2)) { + $modifiedColumns[':p' . $index++] = 'PRICE2'; } - if ($this->isColumnModified(ProductVersionPeer::ECOTAX)) { - $modifiedColumns[':p' . $index++] = '`ecotax`'; + if ($this->isColumnModified(ProductVersionTableMap::ECOTAX)) { + $modifiedColumns[':p' . $index++] = 'ECOTAX'; } - if ($this->isColumnModified(ProductVersionPeer::NEWNESS)) { - $modifiedColumns[':p' . $index++] = '`newness`'; + if ($this->isColumnModified(ProductVersionTableMap::NEWNESS)) { + $modifiedColumns[':p' . $index++] = 'NEWNESS'; } - if ($this->isColumnModified(ProductVersionPeer::PROMO)) { - $modifiedColumns[':p' . $index++] = '`promo`'; + if ($this->isColumnModified(ProductVersionTableMap::PROMO)) { + $modifiedColumns[':p' . $index++] = 'PROMO'; } - if ($this->isColumnModified(ProductVersionPeer::QUANTITY)) { - $modifiedColumns[':p' . $index++] = '`quantity`'; + if ($this->isColumnModified(ProductVersionTableMap::QUANTITY)) { + $modifiedColumns[':p' . $index++] = 'QUANTITY'; } - if ($this->isColumnModified(ProductVersionPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; + if ($this->isColumnModified(ProductVersionTableMap::VISIBLE)) { + $modifiedColumns[':p' . $index++] = 'VISIBLE'; } - if ($this->isColumnModified(ProductVersionPeer::WEIGHT)) { - $modifiedColumns[':p' . $index++] = '`weight`'; + if ($this->isColumnModified(ProductVersionTableMap::WEIGHT)) { + $modifiedColumns[':p' . $index++] = 'WEIGHT'; } - if ($this->isColumnModified(ProductVersionPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; + if ($this->isColumnModified(ProductVersionTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; } - if ($this->isColumnModified(ProductVersionPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(ProductVersionTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(ProductVersionPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(ProductVersionTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } - if ($this->isColumnModified(ProductVersionPeer::VERSION)) { - $modifiedColumns[':p' . $index++] = '`version`'; + if ($this->isColumnModified(ProductVersionTableMap::VERSION)) { + $modifiedColumns[':p' . $index++] = 'VERSION'; } - if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`version_created_at`'; + if ($this->isColumnModified(ProductVersionTableMap::VERSION_CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_AT'; } - if ($this->isColumnModified(ProductVersionPeer::VERSION_CREATED_BY)) { - $modifiedColumns[':p' . $index++] = '`version_created_by`'; + if ($this->isColumnModified(ProductVersionTableMap::VERSION_CREATED_BY)) { + $modifiedColumns[':p' . $index++] = 'VERSION_CREATED_BY'; } $sql = sprintf( - 'INSERT INTO `product_version` (%s) VALUES (%s)', + 'INSERT INTO product_version (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1194,55 +1428,55 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`tax_rule_id`': + case 'TAX_RULE_ID': $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT); break; - case '`ref`': + case 'REF': $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); break; - case '`price`': + case 'PRICE': $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); break; - case '`price2`': + case 'PRICE2': $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR); break; - case '`ecotax`': + case 'ECOTAX': $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR); break; - case '`newness`': + case 'NEWNESS': $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT); break; - case '`promo`': + case 'PROMO': $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT); break; - case '`quantity`': + case 'QUANTITY': $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_INT); break; - case '`visible`': + case 'VISIBLE': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case '`weight`': + case 'WEIGHT': $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); break; - case '`position`': + case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version`': + 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); + case 'VERSION_CREATED_AT': + $stmt->bindValue($identifier, $this->version_created_at ? $this->version_created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`version_created_by`': + case 'VERSION_CREATED_BY': $stmt->bindValue($identifier, $this->version_created_by, PDO::PARAM_STR); break; } @@ -1250,7 +1484,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } $this->setNew(false); @@ -1259,116 +1493,32 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = ProductVersionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ProductVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1378,7 +1528,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1447,22 +1597,22 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = ProductVersionTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getTaxRuleId(), @@ -1482,6 +1632,12 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $keys[15] => $this->getVersionCreatedAt(), $keys[16] => $this->getVersionCreatedBy(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aProduct) { $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -1494,27 +1650,27 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = ProductVersionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ProductVersionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1583,17 +1739,17 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = ProductVersionPeer::getFieldNames($keyType); + $keys = ProductVersionTableMap::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]]); @@ -1621,25 +1777,25 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(ProductVersionPeer::DATABASE_NAME); + $criteria = new Criteria(ProductVersionTableMap::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); + if ($this->isColumnModified(ProductVersionTableMap::ID)) $criteria->add(ProductVersionTableMap::ID, $this->id); + if ($this->isColumnModified(ProductVersionTableMap::TAX_RULE_ID)) $criteria->add(ProductVersionTableMap::TAX_RULE_ID, $this->tax_rule_id); + if ($this->isColumnModified(ProductVersionTableMap::REF)) $criteria->add(ProductVersionTableMap::REF, $this->ref); + if ($this->isColumnModified(ProductVersionTableMap::PRICE)) $criteria->add(ProductVersionTableMap::PRICE, $this->price); + if ($this->isColumnModified(ProductVersionTableMap::PRICE2)) $criteria->add(ProductVersionTableMap::PRICE2, $this->price2); + if ($this->isColumnModified(ProductVersionTableMap::ECOTAX)) $criteria->add(ProductVersionTableMap::ECOTAX, $this->ecotax); + if ($this->isColumnModified(ProductVersionTableMap::NEWNESS)) $criteria->add(ProductVersionTableMap::NEWNESS, $this->newness); + if ($this->isColumnModified(ProductVersionTableMap::PROMO)) $criteria->add(ProductVersionTableMap::PROMO, $this->promo); + if ($this->isColumnModified(ProductVersionTableMap::QUANTITY)) $criteria->add(ProductVersionTableMap::QUANTITY, $this->quantity); + if ($this->isColumnModified(ProductVersionTableMap::VISIBLE)) $criteria->add(ProductVersionTableMap::VISIBLE, $this->visible); + if ($this->isColumnModified(ProductVersionTableMap::WEIGHT)) $criteria->add(ProductVersionTableMap::WEIGHT, $this->weight); + if ($this->isColumnModified(ProductVersionTableMap::POSITION)) $criteria->add(ProductVersionTableMap::POSITION, $this->position); + if ($this->isColumnModified(ProductVersionTableMap::CREATED_AT)) $criteria->add(ProductVersionTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProductVersionTableMap::UPDATED_AT)) $criteria->add(ProductVersionTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(ProductVersionTableMap::VERSION)) $criteria->add(ProductVersionTableMap::VERSION, $this->version); + if ($this->isColumnModified(ProductVersionTableMap::VERSION_CREATED_AT)) $criteria->add(ProductVersionTableMap::VERSION_CREATED_AT, $this->version_created_at); + if ($this->isColumnModified(ProductVersionTableMap::VERSION_CREATED_BY)) $criteria->add(ProductVersionTableMap::VERSION_CREATED_BY, $this->version_created_by); return $criteria; } @@ -1654,9 +1810,9 @@ abstract class BaseProductVersion extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(ProductVersionPeer::DATABASE_NAME); - $criteria->add(ProductVersionPeer::ID, $this->id); - $criteria->add(ProductVersionPeer::VERSION, $this->version); + $criteria = new Criteria(ProductVersionTableMap::DATABASE_NAME); + $criteria->add(ProductVersionTableMap::ID, $this->id); + $criteria->add(ProductVersionTableMap::VERSION, $this->version); return $criteria; } @@ -1678,7 +1834,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** * Set the [composite] primary key. * - * @param array $keys The elements of the composite key (order must match the order in XML file). + * @param array $keys The elements of the composite key (order must match the order in XML file). * @return void */ public function setPrimaryKey($keys) @@ -1703,9 +1859,9 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1727,18 +1883,6 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $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); } @@ -1752,8 +1896,8 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ProductVersion Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1767,31 +1911,13 @@ abstract class BaseProductVersion extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildProduct object. * - * 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) + * @param ChildProduct $v + * @return \Thelia\Model\ProductVersion The current object (for fluent API support) * @throws PropelException */ - public function setProduct(Product $v = null) + public function setProduct(ChildProduct $v = null) { if ($v === null) { $this->setId(NULL); @@ -1802,7 +1928,7 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $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 this object has already been added to the ChildProduct object, it will not be re-added. if ($v !== null) { $v->addProductVersion($this); } @@ -1813,17 +1939,16 @@ abstract class BaseProductVersion extends BaseObject implements Persistent /** - * Get the associated Product object + * Get the associated ChildProduct object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null, $doQuery = true) + public function getProduct(ConnectionInterface $con = null) { - if ($this->aProduct === null && ($this->id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->id, $con); + if ($this->aProduct === null && ($this->id !== null)) { + $this->aProduct = ChildProductQuery::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 @@ -1859,8 +1984,6 @@ abstract class BaseProductVersion extends BaseObject implements Persistent $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(); @@ -1873,42 +1996,144 @@ abstract class BaseProductVersion extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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) { } // if ($deep) $this->aProduct = null; } /** - * return the string representation of this object + * Return the string representation of this object * * @return string */ public function __toString() { - return (string) $this->exportTo(ProductVersionPeer::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(ProductVersionTableMap::DEFAULT_STRING_FORMAT); } /** - * return true is the object is in saving state - * + * Code to be run before persisting the object + * @param ConnectionInterface $con * @return boolean */ - public function isAlreadyInSave() + public function preSave(ConnectionInterface $con = null) { - return $this->alreadyInSave; + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); } } diff --git a/core/lib/Thelia/Model/om/BaseProductVersionQuery.php b/core/lib/Thelia/Model/Base/ProductVersionQuery.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseProductVersionQuery.php rename to core/lib/Thelia/Model/Base/ProductVersionQuery.php index 9d3e71a40..47f94eb9c --- a/core/lib/Thelia/Model/om/BaseProductVersionQuery.php +++ b/core/lib/Thelia/Model/Base/ProductVersionQuery.php @@ -1,140 +1,139 @@ setModelAlias($modelAlias); } @@ -154,23 +153,22 @@ abstract class BaseProductVersionQuery extends ModelCriteria * $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 + * @param array[$id, $version] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ProductVersion|ProductVersion[]|mixed the result, formatted by the current formatter + * @return ChildProductVersion|array|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 + if ((null !== ($obj = ProductVersionTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ProductVersionPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ProductVersionTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -187,14 +185,13 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ProductVersion A model object, or null if the key is not found - * @throws PropelException + * @return ChildProductVersion A model object, or null if the key is not found */ 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'; + $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); @@ -202,13 +199,13 @@ abstract class BaseProductVersionQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ProductVersion(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProductVersion(); $obj->hydrate($row); - ProductVersionPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ProductVersionTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -219,19 +216,19 @@ abstract class BaseProductVersionQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ProductVersion|ProductVersion[]|mixed the result, formatted by the current formatter + * @return ChildProductVersion|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -240,22 +237,22 @@ abstract class BaseProductVersionQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ProductVersion[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -263,12 +260,12 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ProductVersionQuery The current query, for fluid interface + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ProductVersionTableMap::VERSION, $key[1], Criteria::EQUAL); return $this; } @@ -278,7 +275,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ProductVersionQuery The current query, for fluid interface + * @return ChildProductVersionQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -286,8 +283,8 @@ abstract class BaseProductVersionQuery extends ModelCriteria 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 = $this->getNewCriterion(ProductVersionTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ProductVersionTableMap::VERSION, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -302,8 +299,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByProduct() @@ -314,18 +310,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ProductVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -336,7 +332,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::ID, $id, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::ID, $id, $comparison); } /** @@ -346,8 +342,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12 * * * @param mixed $taxRuleId The value to use as filter. @@ -356,18 +351,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::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); + $this->addUsingAlias(ProductVersionTableMap::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -378,7 +373,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::TAX_RULE_ID, $taxRuleId, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::TAX_RULE_ID, $taxRuleId, $comparison); } /** @@ -394,7 +389,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery The current query, for fluid interface */ public function filterByRef($ref = null, $comparison = null) { @@ -407,7 +402,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::REF, $ref, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::REF, $ref, $comparison); } /** @@ -417,8 +412,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByPrice(array('min' => 12)); // WHERE price > 12 * * * @param mixed $price The value to use as filter. @@ -427,18 +421,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::PRICE, $price['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($price['max'])) { - $this->addUsingAlias(ProductVersionPeer::PRICE, $price['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::PRICE, $price['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -449,7 +443,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::PRICE, $price, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::PRICE, $price, $comparison); } /** @@ -459,8 +453,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByPrice2(array('min' => 12)); // WHERE price2 > 12 * * * @param mixed $price2 The value to use as filter. @@ -469,18 +462,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::PRICE2, $price2['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($price2['max'])) { - $this->addUsingAlias(ProductVersionPeer::PRICE2, $price2['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::PRICE2, $price2['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -491,7 +484,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::PRICE2, $price2, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::PRICE2, $price2, $comparison); } /** @@ -501,8 +494,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax > 12 * * * @param mixed $ecotax The value to use as filter. @@ -511,18 +503,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::ECOTAX, $ecotax['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($ecotax['max'])) { - $this->addUsingAlias(ProductVersionPeer::ECOTAX, $ecotax['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::ECOTAX, $ecotax['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -533,7 +525,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::ECOTAX, $ecotax, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::ECOTAX, $ecotax, $comparison); } /** @@ -543,8 +535,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByNewness(array('min' => 12)); // WHERE newness > 12 * * * @param mixed $newness The value to use as filter. @@ -553,18 +544,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($newness['max'])) { - $this->addUsingAlias(ProductVersionPeer::NEWNESS, $newness['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::NEWNESS, $newness['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -575,7 +566,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::NEWNESS, $newness, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::NEWNESS, $newness, $comparison); } /** @@ -585,8 +576,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByPromo(array('min' => 12)); // WHERE promo > 12 * * * @param mixed $promo The value to use as filter. @@ -595,18 +585,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::PROMO, $promo['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($promo['max'])) { - $this->addUsingAlias(ProductVersionPeer::PROMO, $promo['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::PROMO, $promo['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -617,7 +607,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::PROMO, $promo, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::PROMO, $promo, $comparison); } /** @@ -627,8 +617,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByQuantity(array('min' => 12)); // WHERE quantity > 12 * * * @param mixed $quantity The value to use as filter. @@ -637,18 +626,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($quantity['max'])) { - $this->addUsingAlias(ProductVersionPeer::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -659,7 +648,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::QUANTITY, $quantity, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::QUANTITY, $quantity, $comparison); } /** @@ -669,8 +658,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByVisible(array('min' => 12)); // WHERE visible > 12 * * * @param mixed $visible The value to use as filter. @@ -679,18 +667,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($visible['max'])) { - $this->addUsingAlias(ProductVersionPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -701,7 +689,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::VISIBLE, $visible, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::VISIBLE, $visible, $comparison); } /** @@ -711,8 +699,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12 * * * @param mixed $weight The value to use as filter. @@ -721,18 +708,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($weight['max'])) { - $this->addUsingAlias(ProductVersionPeer::WEIGHT, $weight['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::WEIGHT, $weight['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -743,7 +730,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::WEIGHT, $weight, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::WEIGHT, $weight, $comparison); } /** @@ -753,8 +740,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 * * * @param mixed $position The value to use as filter. @@ -763,18 +749,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($position['max'])) { - $this->addUsingAlias(ProductVersionPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -785,7 +771,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::POSITION, $position, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::POSITION, $position, $comparison); } /** @@ -806,18 +792,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ProductVersionPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -828,7 +814,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -849,18 +835,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ProductVersionPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -871,7 +857,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -881,8 +867,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * * $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 + * $query->filterByVersion(array('min' => 12)); // WHERE version > 12 * * * @param mixed $version The value to use as filter. @@ -891,18 +876,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::VERSION, $version['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($version['max'])) { - $this->addUsingAlias(ProductVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ProductVersionTableMap::VERSION, $version['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -913,7 +898,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::VERSION, $version, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::VERSION, $version, $comparison); } /** @@ -934,18 +919,18 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery 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); + $this->addUsingAlias(ProductVersionTableMap::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); + $this->addUsingAlias(ProductVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -956,7 +941,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_AT, $versionCreatedAt, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::VERSION_CREATED_AT, $versionCreatedAt, $comparison); } /** @@ -972,7 +957,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * 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 + * @return ChildProductVersionQuery The current query, for fluid interface */ public function filterByVersionCreatedBy($versionCreatedBy = null, $comparison = null) { @@ -985,32 +970,31 @@ abstract class BaseProductVersionQuery extends ModelCriteria } } - return $this->addUsingAlias(ProductVersionPeer::VERSION_CREATED_BY, $versionCreatedBy, $comparison); + return $this->addUsingAlias(ProductVersionTableMap::VERSION_CREATED_BY, $versionCreatedBy, $comparison); } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildProductVersionQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(ProductVersionPeer::ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(ProductVersionTableMap::ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ProductVersionPeer::ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ProductVersionTableMap::ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -1020,7 +1004,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria * @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 + * @return ChildProductVersionQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -1049,7 +1033,7 @@ abstract class BaseProductVersionQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -1067,19 +1051,94 @@ abstract class BaseProductVersionQuery extends ModelCriteria /** * Exclude object from result * - * @param ProductVersion $productVersion Object to remove from the list of results + * @param ChildProductVersion $productVersion Object to remove from the list of results * - * @return ProductVersionQuery The current query, for fluid interface + * @return ChildProductVersionQuery 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->addCond('pruneCond0', $this->getAliasedColName(ProductVersionTableMap::ID), $productVersion->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ProductVersionTableMap::VERSION), $productVersion->getVersion(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the product_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProductVersionTableMap::clearInstancePool(); + ProductVersionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProductVersion or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProductVersion object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProductVersionTableMap::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(); + + + ProductVersionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProductVersionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ProductVersionQuery diff --git a/core/lib/Thelia/Model/om/BaseResource.php b/core/lib/Thelia/Model/Base/Resource.php old mode 100755 new mode 100644 similarity index 56% rename from core/lib/Thelia/Model/om/BaseResource.php rename to core/lib/Thelia/Model/Base/Resource.php index 9e9c26153..827de2643 --- a/core/lib/Thelia/Model/om/BaseResource.php +++ b/core/lib/Thelia/Model/Base/Resource.php @@ -1,57 +1,65 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Resource instance. If + * obj is an instance of Resource, delegates to + * equals(Resource). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Resource The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Resource The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [code] column value. * - * @return string + * @return string */ public function getCode() { + return $this->code; } @@ -170,97 +422,57 @@ abstract class BaseResource extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Resource The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = ResourcePeer::ID; + $this->modifiedColumns[] = ResourceTableMap::ID; } @@ -270,18 +482,18 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Set the value of [code] column. * - * @param string $v new value - * @return Resource The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Resource The current object (for fluent API support) */ public function setCode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->code !== $v) { $this->code = $v; - $this->modifiedColumns[] = ResourcePeer::CODE; + $this->modifiedColumns[] = ResourceTableMap::CODE; } @@ -291,19 +503,17 @@ abstract class BaseResource extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Resource The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ResourceTableMap::CREATED_AT; } } // if either are not null @@ -314,19 +524,17 @@ abstract class BaseResource extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Resource The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ResourceTableMap::UPDATED_AT; } } // if either are not null @@ -344,7 +552,7 @@ abstract class BaseResource extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -356,20 +564,38 @@ abstract class BaseResource extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ResourceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ResourceTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -377,11 +603,11 @@ abstract class BaseResource extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = ResourcePeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 4; // 4 = ResourceTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Resource object", $e); + throw new PropelException("Error populating \Thelia\Model\Resource object", 0, $e); } } @@ -400,7 +626,6 @@ abstract class BaseResource extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -408,12 +633,12 @@ abstract class BaseResource extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -424,19 +649,19 @@ abstract class BaseResource extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ResourceTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildResourceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -451,26 +676,25 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Resource::setDeleted() + * @see Resource::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ResourceQuery::create() + $deleteQuery = ChildResourceQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -495,20 +719,19 @@ abstract class BaseResource extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -518,16 +741,16 @@ abstract class BaseResource extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(ResourcePeer::CREATED_AT)) { + if (!$this->isColumnModified(ResourceTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(ResourcePeer::UPDATED_AT)) { + if (!$this->isColumnModified(ResourceTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ResourcePeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(ResourceTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -539,7 +762,7 @@ abstract class BaseResource extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - ResourcePeer::addInstanceToPool($this); + ResourceTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -558,12 +781,12 @@ abstract class BaseResource extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -583,10 +806,11 @@ abstract class BaseResource extends BaseObject implements Persistent if ($this->groupsScheduledForDeletion !== null) { if (!$this->groupsScheduledForDeletion->isEmpty()) { $pks = array(); - $pk = $this->getPrimaryKey(); + $pk = $this->getPrimaryKey(); foreach ($this->groupsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($remotePk, $pk); } + GroupResourceQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); @@ -608,15 +832,15 @@ abstract class BaseResource extends BaseObject implements Persistent if ($this->groupResourcesScheduledForDeletion !== null) { if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { - GroupResourceQuery::create() + \Thelia\Model\GroupResourceQuery::create() ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->groupResourcesScheduledForDeletion = null; } } - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { + if ($this->collGroupResources !== null) { + foreach ($this->collGroupResources as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -625,15 +849,15 @@ abstract class BaseResource extends BaseObject implements Persistent if ($this->resourceI18nsScheduledForDeletion !== null) { if (!$this->resourceI18nsScheduledForDeletion->isEmpty()) { - ResourceI18nQuery::create() + \Thelia\Model\ResourceI18nQuery::create() ->filterByPrimaryKeys($this->resourceI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->resourceI18nsScheduledForDeletion = null; } } - if ($this->collResourceI18ns !== null) { - foreach ($this->collResourceI18ns as $referrerFK) { + if ($this->collResourceI18ns !== null) { + foreach ($this->collResourceI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -650,37 +874,37 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = ResourcePeer::ID; + $this->modifiedColumns[] = ResourceTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ResourcePeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ResourceTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ResourcePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(ResourceTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(ResourcePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; + if ($this->isColumnModified(ResourceTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(ResourcePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(ResourceTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(ResourcePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(ResourceTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `resource` (%s) VALUES (%s)', + 'INSERT INTO resource (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -689,30 +913,30 @@ abstract class BaseResource extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`code`': + case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -722,120 +946,32 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = ResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ResourceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -845,7 +981,7 @@ abstract class BaseResource extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -875,28 +1011,34 @@ abstract class BaseResource extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = ResourceTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), $keys[2] => $this->getCreatedAt(), $keys[3] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->collGroupResources) { $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -912,27 +1054,27 @@ abstract class BaseResource extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = ResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = ResourceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -962,17 +1104,17 @@ abstract class BaseResource extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = ResourcePeer::getFieldNames($keyType); + $keys = ResourceTableMap::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]]); @@ -987,12 +1129,12 @@ abstract class BaseResource extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(ResourcePeer::DATABASE_NAME); + $criteria = new Criteria(ResourceTableMap::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); + if ($this->isColumnModified(ResourceTableMap::ID)) $criteria->add(ResourceTableMap::ID, $this->id); + if ($this->isColumnModified(ResourceTableMap::CODE)) $criteria->add(ResourceTableMap::CODE, $this->code); + if ($this->isColumnModified(ResourceTableMap::CREATED_AT)) $criteria->add(ResourceTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ResourceTableMap::UPDATED_AT)) $criteria->add(ResourceTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1007,15 +1149,15 @@ abstract class BaseResource extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(ResourcePeer::DATABASE_NAME); - $criteria->add(ResourcePeer::ID, $this->id); + $criteria = new Criteria(ResourceTableMap::DATABASE_NAME); + $criteria->add(ResourceTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1025,7 +1167,7 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1049,9 +1191,9 @@ abstract class BaseResource extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1060,12 +1202,10 @@ abstract class BaseResource extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1079,8 +1219,6 @@ abstract class BaseResource extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1097,8 +1235,8 @@ abstract class BaseResource extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Resource Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1111,40 +1249,22 @@ abstract class BaseResource extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('GroupResource' == $relationName) { - $this->initGroupResources(); + return $this->initGroupResources(); } if ('ResourceI18n' == $relationName) { - $this->initResourceI18ns(); + return $this->initResourceI18ns(); } } @@ -1154,21 +1274,16 @@ abstract class BaseResource extends BaseObject implements Persistent * This 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) + * @return void * @see addGroupResources() */ public function clearGroupResources() { - $this->collGroupResources = null; // important to set this to null since that means it is uninitialized - $this->collGroupResourcesPartial = null; - - return $this; + $this->collGroupResources = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collGroupResources collection loaded partially - * - * @return void + * Reset is the collGroupResources collection loaded partially. */ public function resetPartialGroupResources($v = true) { @@ -1182,7 +1297,7 @@ abstract class BaseResource extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1192,25 +1307,25 @@ abstract class BaseResource extends BaseObject implements Persistent if (null !== $this->collGroupResources && !$overrideExisting) { return; } - $this->collGroupResources = new PropelObjectCollection(); - $this->collGroupResources->setModel('GroupResource'); + $this->collGroupResources = new ObjectCollection(); + $this->collGroupResources->setModel('\Thelia\Model\GroupResource'); } /** - * Gets an array of GroupResource objects which contain a foreign key that references this object. + * Gets an array of ChildGroupResource objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildResource is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildGroupResource[] List of ChildGroupResource objects * @throws PropelException */ - public function getGroupResources($criteria = null, PropelPDO $con = null) + public function getGroupResources($criteria = null, ConnectionInterface $con = null) { $partial = $this->collGroupResourcesPartial && !$this->isNew(); if (null === $this->collGroupResources || null !== $criteria || $partial) { @@ -1218,29 +1333,31 @@ abstract class BaseResource extends BaseObject implements Persistent // return empty collection $this->initGroupResources(); } else { - $collGroupResources = GroupResourceQuery::create(null, $criteria) + $collGroupResources = ChildGroupResourceQuery::create(null, $criteria) ->filterByResource($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) { - $this->initGroupResources(false); + $this->initGroupResources(false); - foreach($collGroupResources as $obj) { - if (false == $this->collGroupResources->contains($obj)) { - $this->collGroupResources->append($obj); + foreach ($collGroupResources as $obj) { + if (false == $this->collGroupResources->contains($obj)) { + $this->collGroupResources->append($obj); + } } - } - $this->collGroupResourcesPartial = true; + $this->collGroupResourcesPartial = true; } $collGroupResources->getInternalIterator()->rewind(); + return $collGroupResources; } - if($partial && $this->collGroupResources) { - foreach($this->collGroupResources as $obj) { - if($obj->isNew()) { + if ($partial && $this->collGroupResources) { + foreach ($this->collGroupResources as $obj) { + if ($obj->isNew()) { $collGroupResources[] = $obj; } } @@ -1260,15 +1377,19 @@ abstract class BaseResource extends BaseObject implements Persistent * It will 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) + * @param Collection $groupResources A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildResource The current object (for fluent API support) */ - public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null) + public function setGroupResources(Collection $groupResources, ConnectionInterface $con = null) { $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); - $this->groupResourcesScheduledForDeletion = unserialize(serialize($groupResourcesToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->groupResourcesScheduledForDeletion = clone $groupResourcesToDelete; foreach ($groupResourcesToDelete as $groupResourceRemoved) { $groupResourceRemoved->setResource(null); @@ -1288,13 +1409,13 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Returns the number of related GroupResource objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related GroupResource objects. * @throws PropelException */ - public function countGroupResources(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countGroupResources(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collGroupResourcesPartial && !$this->isNew(); if (null === $this->collGroupResources || null !== $criteria || $partial) { @@ -1302,10 +1423,11 @@ abstract class BaseResource extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getGroupResources()); } - $query = GroupResourceQuery::create(null, $criteria); + + $query = ChildGroupResourceQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1319,18 +1441,19 @@ abstract class BaseResource extends BaseObject implements Persistent } /** - * Method called to associate a GroupResource object to this object - * through the GroupResource foreign key attribute. + * Method called to associate a ChildGroupResource object to this object + * through the ChildGroupResource foreign key attribute. * - * @param GroupResource $l GroupResource - * @return Resource The current object (for fluent API support) + * @param ChildGroupResource $l ChildGroupResource + * @return \Thelia\Model\Resource The current object (for fluent API support) */ - public function addGroupResource(GroupResource $l) + public function addGroupResource(ChildGroupResource $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); } @@ -1339,7 +1462,7 @@ abstract class BaseResource extends BaseObject implements Persistent } /** - * @param GroupResource $groupResource The groupResource object to add. + * @param GroupResource $groupResource The groupResource object to add. */ protected function doAddGroupResource($groupResource) { @@ -1348,8 +1471,8 @@ abstract class BaseResource extends BaseObject implements Persistent } /** - * @param GroupResource $groupResource The groupResource object to remove. - * @return Resource The current object (for fluent API support) + * @param GroupResource $groupResource The groupResource object to remove. + * @return ChildResource The current object (for fluent API support) */ public function removeGroupResource($groupResource) { @@ -1378,15 +1501,15 @@ abstract class BaseResource extends BaseObject implements Persistent * 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildGroupResource[] List of ChildGroupResource objects */ - public function getGroupResourcesJoinGroup($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getGroupResourcesJoinGroup($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = GroupResourceQuery::create(null, $criteria); - $query->joinWith('Group', $join_behavior); + $query = ChildGroupResourceQuery::create(null, $criteria); + $query->joinWith('Group', $joinBehavior); return $this->getGroupResources($query, $con); } @@ -1397,21 +1520,16 @@ abstract class BaseResource extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collResourceI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collResourceI18ns collection loaded partially - * - * @return void + * Reset is the collResourceI18ns collection loaded partially. */ public function resetPartialResourceI18ns($v = true) { @@ -1425,7 +1543,7 @@ abstract class BaseResource extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1435,25 +1553,25 @@ abstract class BaseResource extends BaseObject implements Persistent if (null !== $this->collResourceI18ns && !$overrideExisting) { return; } - $this->collResourceI18ns = new PropelObjectCollection(); - $this->collResourceI18ns->setModel('ResourceI18n'); + $this->collResourceI18ns = new ObjectCollection(); + $this->collResourceI18ns->setModel('\Thelia\Model\ResourceI18n'); } /** - * Gets an array of ResourceI18n objects which contain a foreign key that references this object. + * Gets an array of ChildResourceI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildResource is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildResourceI18n[] List of ChildResourceI18n objects * @throws PropelException */ - public function getResourceI18ns($criteria = null, PropelPDO $con = null) + public function getResourceI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collResourceI18nsPartial && !$this->isNew(); if (null === $this->collResourceI18ns || null !== $criteria || $partial) { @@ -1461,29 +1579,31 @@ abstract class BaseResource extends BaseObject implements Persistent // return empty collection $this->initResourceI18ns(); } else { - $collResourceI18ns = ResourceI18nQuery::create(null, $criteria) + $collResourceI18ns = ChildResourceI18nQuery::create(null, $criteria) ->filterByResource($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collResourceI18nsPartial && count($collResourceI18ns)) { - $this->initResourceI18ns(false); + $this->initResourceI18ns(false); - foreach($collResourceI18ns as $obj) { - if (false == $this->collResourceI18ns->contains($obj)) { - $this->collResourceI18ns->append($obj); + foreach ($collResourceI18ns as $obj) { + if (false == $this->collResourceI18ns->contains($obj)) { + $this->collResourceI18ns->append($obj); + } } - } - $this->collResourceI18nsPartial = true; + $this->collResourceI18nsPartial = true; } $collResourceI18ns->getInternalIterator()->rewind(); + return $collResourceI18ns; } - if($partial && $this->collResourceI18ns) { - foreach($this->collResourceI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collResourceI18ns) { + foreach ($this->collResourceI18ns as $obj) { + if ($obj->isNew()) { $collResourceI18ns[] = $obj; } } @@ -1503,15 +1623,19 @@ abstract class BaseResource extends BaseObject implements Persistent * It will 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) + * @param Collection $resourceI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildResource The current object (for fluent API support) */ - public function setResourceI18ns(PropelCollection $resourceI18ns, PropelPDO $con = null) + public function setResourceI18ns(Collection $resourceI18ns, ConnectionInterface $con = null) { $resourceI18nsToDelete = $this->getResourceI18ns(new Criteria(), $con)->diff($resourceI18ns); - $this->resourceI18nsScheduledForDeletion = unserialize(serialize($resourceI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->resourceI18nsScheduledForDeletion = clone $resourceI18nsToDelete; foreach ($resourceI18nsToDelete as $resourceI18nRemoved) { $resourceI18nRemoved->setResource(null); @@ -1531,13 +1655,13 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Returns the number of related ResourceI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related ResourceI18n objects. * @throws PropelException */ - public function countResourceI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countResourceI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collResourceI18nsPartial && !$this->isNew(); if (null === $this->collResourceI18ns || null !== $criteria || $partial) { @@ -1545,10 +1669,11 @@ abstract class BaseResource extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getResourceI18ns()); } - $query = ResourceI18nQuery::create(null, $criteria); + + $query = ChildResourceI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1562,13 +1687,13 @@ abstract class BaseResource extends BaseObject implements Persistent } /** - * Method called to associate a ResourceI18n object to this object - * through the ResourceI18n foreign key attribute. + * Method called to associate a ChildResourceI18n object to this object + * through the ChildResourceI18n foreign key attribute. * - * @param ResourceI18n $l ResourceI18n - * @return Resource The current object (for fluent API support) + * @param ChildResourceI18n $l ChildResourceI18n + * @return \Thelia\Model\Resource The current object (for fluent API support) */ - public function addResourceI18n(ResourceI18n $l) + public function addResourceI18n(ChildResourceI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1578,6 +1703,7 @@ abstract class BaseResource extends BaseObject implements Persistent $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); } @@ -1586,7 +1712,7 @@ abstract class BaseResource extends BaseObject implements Persistent } /** - * @param ResourceI18n $resourceI18n The resourceI18n object to add. + * @param ResourceI18n $resourceI18n The resourceI18n object to add. */ protected function doAddResourceI18n($resourceI18n) { @@ -1595,8 +1721,8 @@ abstract class BaseResource extends BaseObject implements Persistent } /** - * @param ResourceI18n $resourceI18n The resourceI18n object to remove. - * @return Resource The current object (for fluent API support) + * @param ResourceI18n $resourceI18n The resourceI18n object to remove. + * @return ChildResource The current object (for fluent API support) */ public function removeResourceI18n($resourceI18n) { @@ -1619,15 +1745,13 @@ abstract class BaseResource extends BaseObject implements Persistent * This 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) + * @return void * @see addGroups() */ public function clearGroups() { - $this->collGroups = null; // important to set this to null since that means it is uninitialized + $this->collGroups = null; // important to set this to NULL since that means it is uninitialized $this->collGroupsPartial = null; - - return $this; } /** @@ -1641,33 +1765,33 @@ abstract class BaseResource extends BaseObject implements Persistent */ public function initGroups() { - $this->collGroups = new PropelObjectCollection(); - $this->collGroups->setModel('Group'); + $this->collGroups = new ObjectCollection(); + $this->collGroups->setModel('\Thelia\Model\Group'); } /** - * Gets a collection of Group objects related by a many-to-many relationship + * Gets a collection of ChildGroup 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 + * If this ChildResource 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 + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object * - * @return PropelObjectCollection|Group[] List of Group objects + * @return ObjectCollection|ChildGroup[] List of ChildGroup objects */ - public function getGroups($criteria = null, PropelPDO $con = null) + public function getGroups($criteria = null, ConnectionInterface $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) + $collGroups = ChildGroupQuery::create(null, $criteria) ->filterByResource($this) ->find($con); if (null !== $criteria) { @@ -1686,11 +1810,11 @@ abstract class BaseResource extends BaseObject implements Persistent * It will 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) + * @param Collection $groups A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildResource The current object (for fluent API support) */ - public function setGroups(PropelCollection $groups, PropelPDO $con = null) + public function setGroups(Collection $groups, ConnectionInterface $con = null) { $this->clearGroups(); $currentGroups = $this->getGroups(); @@ -1709,22 +1833,22 @@ abstract class BaseResource extends BaseObject implements Persistent } /** - * Gets the number of Group objects related by a many-to-many relationship + * Gets the number of ChildGroup 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 + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object * - * @return int the number of related Group objects + * @return int the number of related ChildGroup objects */ - public function countGroups($criteria = null, $distinct = false, PropelPDO $con = null) + public function countGroups($criteria = null, $distinct = false, ConnectionInterface $con = null) { if (null === $this->collGroups || null !== $criteria) { if ($this->isNew() && null === $this->collGroups) { return 0; } else { - $query = GroupQuery::create(null, $criteria); + $query = ChildGroupQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1739,52 +1863,60 @@ abstract class BaseResource extends BaseObject implements Persistent } /** - * Associate a Group object to this object + * Associate a ChildGroup 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) + * @param ChildGroup $group The ChildGroupResource object to relate + * @return ChildResource The current object (for fluent API support) */ - public function addGroup(Group $group) + public function addGroup(ChildGroup $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; + $this->collGroups[] = $group; } return $this; } /** - * @param Group $group The group object to add. + * @param Group $group The group object to add. */ protected function doAddGroup($group) { - $groupResource = new GroupResource(); + $groupResource = new ChildGroupResource(); $groupResource->setGroup($group); $this->addGroupResource($groupResource); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$group->getResources()->contains($this)) { + $foreignCollection = $group->getResources(); + $foreignCollection[] = $this; + } } /** - * Remove a Group object to this object + * Remove a ChildGroup 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) + * @param ChildGroup $group The ChildGroupResource object to relate + * @return ChildResource The current object (for fluent API support) */ - public function removeGroup(Group $group) + public function removeGroup(ChildGroup $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; + + $this->groupsScheduledForDeletion[] = $group; } return $this; @@ -1800,8 +1932,6 @@ abstract class BaseResource extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1813,14 +1943,13 @@ abstract class BaseResource extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collGroupResources) { foreach ($this->collGroupResources as $o) { $o->clearAllReferences($deep); @@ -1836,46 +1965,34 @@ abstract class BaseResource extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collGroupResources instanceof PropelCollection) { + if ($this->collGroupResources instanceof Collection) { $this->collGroupResources->clearIterator(); } $this->collGroupResources = null; - if ($this->collResourceI18ns instanceof PropelCollection) { + if ($this->collResourceI18ns instanceof Collection) { $this->collResourceI18ns->clearIterator(); } $this->collResourceI18ns = null; - if ($this->collGroups instanceof PropelCollection) { + if ($this->collGroups instanceof Collection) { $this->collGroups->clearIterator(); } $this->collGroups = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(ResourceTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1883,11 +2000,11 @@ abstract class BaseResource extends BaseObject implements Persistent /** * 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) + * @return ChildResource The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = ResourcePeer::UPDATED_AT; + $this->modifiedColumns[] = ResourceTableMap::UPDATED_AT; return $this; } @@ -1899,9 +2016,9 @@ abstract class BaseResource extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return Resource The current object (for fluent API support) + * @return ChildResource The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -1922,10 +2039,10 @@ abstract class BaseResource extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return ResourceI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildResourceI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collResourceI18ns) { @@ -1938,10 +2055,10 @@ abstract class BaseResource extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new ResourceI18n(); + $translation = new ChildResourceI18n(); $translation->setLocale($locale); } else { - $translation = ResourceI18nQuery::create() + $translation = ChildResourceI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -1956,14 +2073,14 @@ abstract class BaseResource extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return Resource The current object (for fluent API support) + * @return ChildResource The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - ResourceI18nQuery::create() + ChildResourceI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -1983,10 +2100,10 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return ResourceI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildResourceI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } @@ -1995,7 +2112,7 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { @@ -2006,8 +2123,8 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ResourceI18n The current object (for fluent API support) */ public function setTitle($v) { $this->getCurrentTranslation()->setTitle($v); @@ -2019,7 +2136,7 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { @@ -2030,8 +2147,8 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ResourceI18n The current object (for fluent API support) */ public function setDescription($v) { $this->getCurrentTranslation()->setDescription($v); @@ -2043,7 +2160,7 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Get the [chapo] column value. * - * @return string + * @return string */ public function getChapo() { @@ -2054,8 +2171,8 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Set the value of [chapo] column. * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ResourceI18n The current object (for fluent API support) */ public function setChapo($v) { $this->getCurrentTranslation()->setChapo($v); @@ -2067,7 +2184,7 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Get the [postscriptum] column value. * - * @return string + * @return string */ public function getPostscriptum() { @@ -2078,8 +2195,8 @@ abstract class BaseResource extends BaseObject implements Persistent /** * Set the value of [postscriptum] column. * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\ResourceI18n The current object (for fluent API support) */ public function setPostscriptum($v) { $this->getCurrentTranslation()->setPostscriptum($v); @@ -2087,4 +2204,122 @@ abstract class BaseResource extends BaseObject implements Persistent return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/ResourceI18n.php b/core/lib/Thelia/Model/Base/ResourceI18n.php new file mode 100644 index 000000000..b740bd858 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ResourceI18n.php @@ -0,0 +1,1439 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ResourceI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ResourceI18n instance. If + * obj is an instance of ResourceI18n, delegates to + * equals(ResourceI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ResourceI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ResourceI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\ResourceI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ResourceI18nTableMap::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 \Thelia\Model\ResourceI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ResourceI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ResourceI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ResourceI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ResourceI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ResourceI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ResourceI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ResourceI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ResourceI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ResourceI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ResourceI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ResourceI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ResourceI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ResourceI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ResourceI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ResourceI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ResourceI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ResourceI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(ResourceI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildResourceI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aResource = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ResourceI18n::setDeleted() + * @see ResourceI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildResourceI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME); + } + + $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); + ResourceI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ResourceI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ResourceI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ResourceI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ResourceI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ResourceI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ResourceI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ResourceI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ResourceI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ResourceI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ResourceI18nTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ResourceI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = ResourceI18nTableMap::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(ResourceI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ResourceI18nTableMap::ID)) $criteria->add(ResourceI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ResourceI18nTableMap::LOCALE)) $criteria->add(ResourceI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ResourceI18nTableMap::TITLE)) $criteria->add(ResourceI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ResourceI18nTableMap::DESCRIPTION)) $criteria->add(ResourceI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ResourceI18nTableMap::CHAPO)) $criteria->add(ResourceI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ResourceI18nTableMap::POSTSCRIPTUM)) $criteria->add(ResourceI18nTableMap::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(ResourceI18nTableMap::DATABASE_NAME); + $criteria->add(ResourceI18nTableMap::ID, $this->id); + $criteria->add(ResourceI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildResource object. + * + * @param ChildResource $v + * @return \Thelia\Model\ResourceI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setResource(ChildResource $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 ChildResource object, it will not be re-added. + if ($v !== null) { + $v->addResourceI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildResource object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildResource The associated ChildResource object. + * @throws PropelException + */ + public function getResource(ConnectionInterface $con = null) + { + if ($this->aResource === null && ($this->id !== null)) { + $this->aResource = ChildResourceQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aResource = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ResourceI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseResourceI18nQuery.php b/core/lib/Thelia/Model/Base/ResourceI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseResourceI18nQuery.php rename to core/lib/Thelia/Model/Base/ResourceI18nQuery.php index e37525132..8c9872943 --- a/core/lib/Thelia/Model/om/BaseResourceI18nQuery.php +++ b/core/lib/Thelia/Model/Base/ResourceI18nQuery.php @@ -1,96 +1,95 @@ setModelAlias($modelAlias); } @@ -110,23 +109,22 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return ResourceI18n|ResourceI18n[]|mixed the result, formatted by the current formatter + * @return ChildResourceI18n|array|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 + if ((null !== ($obj = ResourceI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ResourceI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ResourceI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -143,14 +141,13 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return ResourceI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildResourceI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `resource_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -158,13 +155,13 @@ abstract class BaseResourceI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ResourceI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildResourceI18n(); $obj->hydrate($row); - ResourceI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + ResourceI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -175,19 +172,19 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return ResourceI18n|ResourceI18n[]|mixed the result, formatted by the current formatter + * @return ChildResourceI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -196,22 +193,22 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|ResourceI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -219,12 +216,12 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ResourceI18nQuery The current query, for fluid interface + * @return ChildResourceI18nQuery 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); + $this->addUsingAlias(ResourceI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ResourceI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -234,7 +231,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ResourceI18nQuery The current query, for fluid interface + * @return ChildResourceI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -242,8 +239,8 @@ abstract class BaseResourceI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(ResourceI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ResourceI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -258,8 +255,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByResource() @@ -270,18 +266,18 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * 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 + * @return ChildResourceI18nQuery 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); + $this->addUsingAlias(ResourceI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ResourceI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ResourceI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -292,7 +288,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourceI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(ResourceI18nTableMap::ID, $id, $comparison); } /** @@ -308,7 +304,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * 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 + * @return ChildResourceI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -321,7 +317,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourceI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(ResourceI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -337,7 +333,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * 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 + * @return ChildResourceI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -350,7 +346,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourceI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(ResourceI18nTableMap::TITLE, $title, $comparison); } /** @@ -366,7 +362,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * 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 + * @return ChildResourceI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -379,7 +375,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourceI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(ResourceI18nTableMap::DESCRIPTION, $description, $comparison); } /** @@ -395,7 +391,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * 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 + * @return ChildResourceI18nQuery The current query, for fluid interface */ public function filterByChapo($chapo = null, $comparison = null) { @@ -408,7 +404,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourceI18nPeer::CHAPO, $chapo, $comparison); + return $this->addUsingAlias(ResourceI18nTableMap::CHAPO, $chapo, $comparison); } /** @@ -424,7 +420,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * 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 + * @return ChildResourceI18nQuery The current query, for fluid interface */ public function filterByPostscriptum($postscriptum = null, $comparison = null) { @@ -437,32 +433,31 @@ abstract class BaseResourceI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourceI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); + return $this->addUsingAlias(ResourceI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); } /** - * Filter the query by a related Resource object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Resource|ObjectCollection $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. + * @return ChildResourceI18nQuery The current query, for fluid interface */ public function filterByResource($resource, $comparison = null) { - if ($resource instanceof Resource) { + if ($resource instanceof \Thelia\Model\Resource) { return $this - ->addUsingAlias(ResourceI18nPeer::ID, $resource->getId(), $comparison); - } elseif ($resource instanceof PropelObjectCollection) { + ->addUsingAlias(ResourceI18nTableMap::ID, $resource->getId(), $comparison); + } elseif ($resource instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(ResourceI18nPeer::ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(ResourceI18nTableMap::ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection'); + throw new PropelException('filterByResource() only accepts arguments of type \Thelia\Model\Resource or Collection'); } } @@ -472,7 +467,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria * @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 + * @return ChildResourceI18nQuery The current query, for fluid interface */ public function joinResource($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -501,7 +496,7 @@ abstract class BaseResourceI18nQuery extends ModelCriteria /** * Use the Resource relation Resource object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -519,19 +514,94 @@ abstract class BaseResourceI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param ResourceI18n $resourceI18n Object to remove from the list of results + * @param ChildResourceI18n $resourceI18n Object to remove from the list of results * - * @return ResourceI18nQuery The current query, for fluid interface + * @return ChildResourceI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(ResourceI18nTableMap::ID), $resourceI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ResourceI18nTableMap::LOCALE), $resourceI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the resource_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ResourceI18nTableMap::clearInstancePool(); + ResourceI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildResourceI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildResourceI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ResourceI18nTableMap::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(); + + + ResourceI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ResourceI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ResourceI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseResourceQuery.php b/core/lib/Thelia/Model/Base/ResourceQuery.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseResourceQuery.php rename to core/lib/Thelia/Model/Base/ResourceQuery.php index f390091ec..e12ee8f53 --- a/core/lib/Thelia/Model/om/BaseResourceQuery.php +++ b/core/lib/Thelia/Model/Base/ResourceQuery.php @@ -1,93 +1,92 @@ setModelAlias($modelAlias); } @@ -108,21 +107,21 @@ abstract class BaseResourceQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Resource|Resource[]|mixed the result, formatted by the current formatter + * @return ChildResource|array|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 + if ((null !== ($obj = ResourceTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(ResourceTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -134,46 +133,31 @@ abstract class BaseResourceQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Resource A model object, or null if the key is not found - * @throws PropelException + * @return ChildResource A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `resource` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Resource(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildResource(); $obj->hydrate($row); - ResourcePeer::addInstanceToPool($obj, (string) $key); + ResourceTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -184,19 +168,19 @@ abstract class BaseResourceQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Resource|Resource[]|mixed the result, formatted by the current formatter + * @return ChildResource|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -205,22 +189,22 @@ abstract class BaseResourceQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Resource[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -228,12 +212,12 @@ abstract class BaseResourceQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ResourceQuery The current query, for fluid interface + * @return ChildResourceQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(ResourcePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(ResourceTableMap::ID, $key, Criteria::EQUAL); } /** @@ -241,12 +225,12 @@ abstract class BaseResourceQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ResourceQuery The current query, for fluid interface + * @return ChildResourceQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(ResourcePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(ResourceTableMap::ID, $keys, Criteria::IN); } /** @@ -256,8 +240,7 @@ abstract class BaseResourceQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -266,18 +249,18 @@ abstract class BaseResourceQuery extends ModelCriteria * 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 + * @return ChildResourceQuery 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); + $this->addUsingAlias(ResourceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(ResourcePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ResourceTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -288,7 +271,7 @@ abstract class BaseResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourcePeer::ID, $id, $comparison); + return $this->addUsingAlias(ResourceTableMap::ID, $id, $comparison); } /** @@ -304,7 +287,7 @@ abstract class BaseResourceQuery extends ModelCriteria * 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 + * @return ChildResourceQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -317,7 +300,7 @@ abstract class BaseResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourcePeer::CODE, $code, $comparison); + return $this->addUsingAlias(ResourceTableMap::CODE, $code, $comparison); } /** @@ -338,18 +321,18 @@ abstract class BaseResourceQuery extends ModelCriteria * 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 + * @return ChildResourceQuery 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); + $this->addUsingAlias(ResourceTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ResourceTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -360,7 +343,7 @@ abstract class BaseResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(ResourceTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -381,18 +364,18 @@ abstract class BaseResourceQuery extends ModelCriteria * 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 + * @return ChildResourceQuery 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); + $this->addUsingAlias(ResourceTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(ResourceTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -403,30 +386,29 @@ abstract class BaseResourceQuery extends ModelCriteria } } - return $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(ResourceTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related GroupResource object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\GroupResource|ObjectCollection $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. + * @return ChildResourceQuery The current query, for fluid interface */ public function filterByGroupResource($groupResource, $comparison = null) { - if ($groupResource instanceof GroupResource) { + if ($groupResource instanceof \Thelia\Model\GroupResource) { return $this - ->addUsingAlias(ResourcePeer::ID, $groupResource->getResourceId(), $comparison); - } elseif ($groupResource instanceof PropelObjectCollection) { + ->addUsingAlias(ResourceTableMap::ID, $groupResource->getResourceId(), $comparison); + } elseif ($groupResource instanceof ObjectCollection) { return $this ->useGroupResourceQuery() ->filterByPrimaryKeys($groupResource->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection'); + throw new PropelException('filterByGroupResource() only accepts arguments of type \Thelia\Model\GroupResource or Collection'); } } @@ -436,7 +418,7 @@ abstract class BaseResourceQuery extends ModelCriteria * @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 + * @return ChildResourceQuery The current query, for fluid interface */ public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -465,7 +447,7 @@ abstract class BaseResourceQuery extends ModelCriteria /** * Use the GroupResource relation GroupResource object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -481,26 +463,25 @@ abstract class BaseResourceQuery extends ModelCriteria } /** - * Filter the query by a related ResourceI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\ResourceI18n|ObjectCollection $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. + * @return ChildResourceQuery The current query, for fluid interface */ public function filterByResourceI18n($resourceI18n, $comparison = null) { - if ($resourceI18n instanceof ResourceI18n) { + if ($resourceI18n instanceof \Thelia\Model\ResourceI18n) { return $this - ->addUsingAlias(ResourcePeer::ID, $resourceI18n->getId(), $comparison); - } elseif ($resourceI18n instanceof PropelObjectCollection) { + ->addUsingAlias(ResourceTableMap::ID, $resourceI18n->getId(), $comparison); + } elseif ($resourceI18n instanceof ObjectCollection) { return $this ->useResourceI18nQuery() ->filterByPrimaryKeys($resourceI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByResourceI18n() only accepts arguments of type ResourceI18n or PropelCollection'); + throw new PropelException('filterByResourceI18n() only accepts arguments of type \Thelia\Model\ResourceI18n or Collection'); } } @@ -510,7 +491,7 @@ abstract class BaseResourceQuery extends ModelCriteria * @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 + * @return ChildResourceQuery The current query, for fluid interface */ public function joinResourceI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -539,7 +520,7 @@ abstract class BaseResourceQuery extends ModelCriteria /** * Use the ResourceI18n relation ResourceI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -558,10 +539,10 @@ abstract class BaseResourceQuery extends ModelCriteria * 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 + * @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 + * @return ChildResourceQuery The current query, for fluid interface */ public function filterByGroup($group, $comparison = Criteria::EQUAL) { @@ -574,19 +555,94 @@ abstract class BaseResourceQuery extends ModelCriteria /** * Exclude object from result * - * @param Resource $resource Object to remove from the list of results + * @param ChildResource $resource Object to remove from the list of results * - * @return ResourceQuery The current query, for fluid interface + * @return ChildResourceQuery The current query, for fluid interface */ public function prune($resource = null) { if ($resource) { - $this->addUsingAlias(ResourcePeer::ID, $resource->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(ResourceTableMap::ID, $resource->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the resource table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ResourceTableMap::clearInstancePool(); + ResourceTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildResource or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildResource object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ResourceTableMap::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(); + + + ResourceTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ResourceTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -594,31 +650,11 @@ abstract class BaseResourceQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ResourceQuery The current query, for fluid interface + * @return ChildResourceQuery 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); + return $this->addUsingAlias(ResourceTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -626,32 +662,53 @@ abstract class BaseResourceQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ResourceQuery The current query, for fluid interface + * @return ChildResourceQuery 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); + return $this->addUsingAlias(ResourceTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildResourceQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ResourceTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildResourceQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ResourceTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ResourceQuery The current query, for fluid interface + * @return ChildResourceQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(ResourcePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(ResourceTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ResourceQuery The current query, for fluid interface + * @return ChildResourceQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(ResourcePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(ResourceTableMap::CREATED_AT); } + // i18n behavior /** @@ -661,9 +718,9 @@ abstract class BaseResourceQuery extends ModelCriteria * @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 + * @return ChildResourceQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ResourceI18n'; @@ -679,9 +736,9 @@ abstract class BaseResourceQuery extends ModelCriteria * @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 + * @return ChildResourceQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -700,13 +757,13 @@ abstract class BaseResourceQuery extends ModelCriteria * @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 + * @return ChildResourceI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ResourceI18n', 'Thelia\Model\ResourceI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'ResourceI18n', '\Thelia\Model\ResourceI18nQuery'); } -} +} // ResourceQuery diff --git a/core/lib/Thelia/Model/om/BaseRewriting.php b/core/lib/Thelia/Model/Base/Rewriting.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseRewriting.php rename to core/lib/Thelia/Model/Base/Rewriting.php index 4cfcdb7f7..12229c438 --- a/core/lib/Thelia/Model/om/BaseRewriting.php +++ b/core/lib/Thelia/Model/Base/Rewriting.php @@ -1,57 +1,66 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Rewriting instance. If + * obj is an instance of Rewriting, delegates to + * equals(Rewriting). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Rewriting The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Rewriting The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [url] column value. * - * @return string + * @return string */ public function getUrl() { + return $this->url; } /** * Get the [product_id] column value. * - * @return int + * @return int */ public function getProductId() { + return $this->product_id; } /** * Get the [category_id] column value. * - * @return int + * @return int */ public function getCategoryId() { + return $this->category_id; } /** * Get the [folder_id] column value. * - * @return int + * @return int */ public function getFolderId() { + return $this->folder_id; } /** * Get the [content_id] column value. * - * @return int + * @return int */ public function getContentId() { + return $this->content_id; } @@ -205,97 +462,57 @@ abstract class BaseRewriting extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\Rewriting The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = RewritingPeer::ID; + $this->modifiedColumns[] = RewritingTableMap::ID; } @@ -305,18 +522,18 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * Set the value of [url] column. * - * @param string $v new value - * @return Rewriting The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\Rewriting The current object (for fluent API support) */ public function setUrl($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->url !== $v) { $this->url = $v; - $this->modifiedColumns[] = RewritingPeer::URL; + $this->modifiedColumns[] = RewritingTableMap::URL; } @@ -326,18 +543,18 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * Set the value of [product_id] column. * - * @param int $v new value - * @return Rewriting The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Rewriting The current object (for fluent API support) */ public function setProductId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->product_id !== $v) { $this->product_id = $v; - $this->modifiedColumns[] = RewritingPeer::PRODUCT_ID; + $this->modifiedColumns[] = RewritingTableMap::PRODUCT_ID; } if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { @@ -351,18 +568,18 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * Set the value of [category_id] column. * - * @param int $v new value - * @return Rewriting The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Rewriting The current object (for fluent API support) */ public function setCategoryId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->category_id !== $v) { $this->category_id = $v; - $this->modifiedColumns[] = RewritingPeer::CATEGORY_ID; + $this->modifiedColumns[] = RewritingTableMap::CATEGORY_ID; } if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { @@ -376,18 +593,18 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * Set the value of [folder_id] column. * - * @param int $v new value - * @return Rewriting The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Rewriting The current object (for fluent API support) */ public function setFolderId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->folder_id !== $v) { $this->folder_id = $v; - $this->modifiedColumns[] = RewritingPeer::FOLDER_ID; + $this->modifiedColumns[] = RewritingTableMap::FOLDER_ID; } if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { @@ -401,18 +618,18 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * Set the value of [content_id] column. * - * @param int $v new value - * @return Rewriting The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\Rewriting The current object (for fluent API support) */ public function setContentId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->content_id !== $v) { $this->content_id = $v; - $this->modifiedColumns[] = RewritingPeer::CONTENT_ID; + $this->modifiedColumns[] = RewritingTableMap::CONTENT_ID; } if ($this->aContent !== null && $this->aContent->getId() !== $v) { @@ -426,19 +643,17 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Rewriting The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = RewritingTableMap::CREATED_AT; } } // if either are not null @@ -449,19 +664,17 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Rewriting The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = RewritingTableMap::UPDATED_AT; } } // if either are not null @@ -479,7 +692,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -491,24 +704,50 @@ abstract class BaseRewriting extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : RewritingTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : RewritingTableMap::translateFieldName('Url', TableMap::TYPE_PHPNAME, $indexType)]; + $this->url = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : RewritingTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : RewritingTableMap::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->category_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : RewritingTableMap::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->folder_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : RewritingTableMap::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->content_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : RewritingTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : RewritingTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -516,11 +755,11 @@ abstract class BaseRewriting extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = RewritingPeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 8; // 8 = RewritingTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating Rewriting object", $e); + throw new PropelException("Error populating \Thelia\Model\Rewriting object", 0, $e); } } @@ -539,7 +778,6 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function ensureConsistency() { - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { $this->aProduct = null; } @@ -559,12 +797,12 @@ abstract class BaseRewriting extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -575,19 +813,19 @@ abstract class BaseRewriting extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(RewritingTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildRewritingQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? @@ -601,26 +839,25 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see Rewriting::setDeleted() + * @see Rewriting::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = RewritingQuery::create() + $deleteQuery = ChildRewritingQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -645,20 +882,19 @@ abstract class BaseRewriting extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -668,16 +904,16 @@ abstract class BaseRewriting extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(RewritingPeer::CREATED_AT)) { + if (!$this->isColumnModified(RewritingTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(RewritingPeer::UPDATED_AT)) { + if (!$this->isColumnModified(RewritingTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(RewritingPeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(RewritingTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -689,7 +925,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - RewritingPeer::addInstanceToPool($this); + RewritingTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -708,19 +944,19 @@ abstract class BaseRewriting extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $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 + // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. @@ -773,45 +1009,45 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $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(RewritingTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(RewritingPeer::URL)) { - $modifiedColumns[':p' . $index++] = '`url`'; + if ($this->isColumnModified(RewritingTableMap::URL)) { + $modifiedColumns[':p' . $index++] = 'URL'; } - if ($this->isColumnModified(RewritingPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; + if ($this->isColumnModified(RewritingTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; } - if ($this->isColumnModified(RewritingPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; + if ($this->isColumnModified(RewritingTableMap::CATEGORY_ID)) { + $modifiedColumns[':p' . $index++] = 'CATEGORY_ID'; } - if ($this->isColumnModified(RewritingPeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`folder_id`'; + if ($this->isColumnModified(RewritingTableMap::FOLDER_ID)) { + $modifiedColumns[':p' . $index++] = 'FOLDER_ID'; } - if ($this->isColumnModified(RewritingPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`content_id`'; + if ($this->isColumnModified(RewritingTableMap::CONTENT_ID)) { + $modifiedColumns[':p' . $index++] = 'CONTENT_ID'; } - if ($this->isColumnModified(RewritingPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(RewritingTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(RewritingPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(RewritingTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `rewriting` (%s) VALUES (%s)', + 'INSERT INTO rewriting (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -820,36 +1056,36 @@ abstract class BaseRewriting extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`url`': + case 'URL': $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); break; - case '`product_id`': + case 'PRODUCT_ID': $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); break; - case '`category_id`': + case 'CATEGORY_ID': $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); break; - case '`folder_id`': + case 'FOLDER_ID': $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); break; - case '`content_id`': + 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); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } $this->setNew(false); @@ -858,134 +1094,32 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = RewritingPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = RewritingTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -995,7 +1129,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -1037,22 +1171,22 @@ abstract class BaseRewriting extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = RewritingTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getUrl(), @@ -1063,6 +1197,12 @@ abstract class BaseRewriting extends BaseObject implements Persistent $keys[6] => $this->getCreatedAt(), $keys[7] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + if ($includeForeignObjects) { if (null !== $this->aProduct) { $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); @@ -1084,27 +1224,27 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = RewritingPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = RewritingTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1146,17 +1286,17 @@ abstract class BaseRewriting extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = RewritingPeer::getFieldNames($keyType); + $keys = RewritingTableMap::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]]); @@ -1175,16 +1315,16 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(RewritingPeer::DATABASE_NAME); + $criteria = new Criteria(RewritingTableMap::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); + if ($this->isColumnModified(RewritingTableMap::ID)) $criteria->add(RewritingTableMap::ID, $this->id); + if ($this->isColumnModified(RewritingTableMap::URL)) $criteria->add(RewritingTableMap::URL, $this->url); + if ($this->isColumnModified(RewritingTableMap::PRODUCT_ID)) $criteria->add(RewritingTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(RewritingTableMap::CATEGORY_ID)) $criteria->add(RewritingTableMap::CATEGORY_ID, $this->category_id); + if ($this->isColumnModified(RewritingTableMap::FOLDER_ID)) $criteria->add(RewritingTableMap::FOLDER_ID, $this->folder_id); + if ($this->isColumnModified(RewritingTableMap::CONTENT_ID)) $criteria->add(RewritingTableMap::CONTENT_ID, $this->content_id); + if ($this->isColumnModified(RewritingTableMap::CREATED_AT)) $criteria->add(RewritingTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(RewritingTableMap::UPDATED_AT)) $criteria->add(RewritingTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1199,15 +1339,15 @@ abstract class BaseRewriting extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(RewritingPeer::DATABASE_NAME); - $criteria->add(RewritingPeer::ID, $this->id); + $criteria = new Criteria(RewritingTableMap::DATABASE_NAME); + $criteria->add(RewritingTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1217,7 +1357,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1241,13 +1381,14 @@ abstract class BaseRewriting extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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->setId($this->getId()); $copyObj->setUrl($this->getUrl()); $copyObj->setProductId($this->getProductId()); $copyObj->setCategoryId($this->getCategoryId()); @@ -1255,21 +1396,8 @@ abstract class BaseRewriting extends BaseObject implements Persistent $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 } } @@ -1281,8 +1409,8 @@ abstract class BaseRewriting extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Rewriting Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1296,31 +1424,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent } /** - * Returns a peer instance associated with this om. + * Declares an association between this object and a ChildProduct object. * - * 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) + * @param ChildProduct $v + * @return \Thelia\Model\Rewriting The current object (for fluent API support) * @throws PropelException */ - public function setProduct(Product $v = null) + public function setProduct(ChildProduct $v = null) { if ($v === null) { $this->setProductId(NULL); @@ -1331,7 +1441,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent $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 this object has already been added to the ChildProduct object, it will not be re-added. if ($v !== null) { $v->addRewriting($this); } @@ -1342,17 +1452,16 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** - * Get the associated Product object + * Get the associated ChildProduct object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. * @throws PropelException */ - public function getProduct(PropelPDO $con = null, $doQuery = true) + public function getProduct(ConnectionInterface $con = null) { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::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 @@ -1366,13 +1475,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent } /** - * Declares an association between this object and a Category object. + * Declares an association between this object and a ChildCategory object. * - * @param Category $v - * @return Rewriting The current object (for fluent API support) + * @param ChildCategory $v + * @return \Thelia\Model\Rewriting The current object (for fluent API support) * @throws PropelException */ - public function setCategory(Category $v = null) + public function setCategory(ChildCategory $v = null) { if ($v === null) { $this->setCategoryId(NULL); @@ -1383,7 +1492,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent $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 this object has already been added to the ChildCategory object, it will not be re-added. if ($v !== null) { $v->addRewriting($this); } @@ -1394,17 +1503,16 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** - * Get the associated Category object + * Get the associated ChildCategory object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCategory The associated ChildCategory object. * @throws PropelException */ - public function getCategory(PropelPDO $con = null, $doQuery = true) + public function getCategory(ConnectionInterface $con = null) { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); + if ($this->aCategory === null && ($this->category_id !== null)) { + $this->aCategory = ChildCategoryQuery::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 @@ -1418,13 +1526,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent } /** - * Declares an association between this object and a Folder object. + * Declares an association between this object and a ChildFolder object. * - * @param Folder $v - * @return Rewriting The current object (for fluent API support) + * @param ChildFolder $v + * @return \Thelia\Model\Rewriting The current object (for fluent API support) * @throws PropelException */ - public function setFolder(Folder $v = null) + public function setFolder(ChildFolder $v = null) { if ($v === null) { $this->setFolderId(NULL); @@ -1435,7 +1543,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent $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 this object has already been added to the ChildFolder object, it will not be re-added. if ($v !== null) { $v->addRewriting($this); } @@ -1446,17 +1554,16 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** - * Get the associated Folder object + * Get the associated ChildFolder object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Folder The associated Folder object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildFolder The associated ChildFolder object. * @throws PropelException */ - public function getFolder(PropelPDO $con = null, $doQuery = true) + public function getFolder(ConnectionInterface $con = null) { - if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { - $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); + if ($this->aFolder === null && ($this->folder_id !== null)) { + $this->aFolder = ChildFolderQuery::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 @@ -1470,13 +1577,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent } /** - * Declares an association between this object and a Content object. + * Declares an association between this object and a ChildContent object. * - * @param Content $v - * @return Rewriting The current object (for fluent API support) + * @param ChildContent $v + * @return \Thelia\Model\Rewriting The current object (for fluent API support) * @throws PropelException */ - public function setContent(Content $v = null) + public function setContent(ChildContent $v = null) { if ($v === null) { $this->setContentId(NULL); @@ -1487,7 +1594,7 @@ abstract class BaseRewriting extends BaseObject implements Persistent $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 this object has already been added to the ChildContent object, it will not be re-added. if ($v !== null) { $v->addRewriting($this); } @@ -1498,17 +1605,16 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** - * Get the associated Content object + * Get the associated ChildContent object * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. + * @param ConnectionInterface $con Optional Connection object. + * @return ChildContent The associated ChildContent object. * @throws PropelException */ - public function getContent(PropelPDO $con = null, $doQuery = true) + public function getContent(ConnectionInterface $con = null) { - if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); + if ($this->aContent === null && ($this->content_id !== null)) { + $this->aContent = ChildContentQuery::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 @@ -1535,8 +1641,6 @@ abstract class BaseRewriting extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -1548,28 +1652,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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) { } // if ($deep) $this->aProduct = null; @@ -1579,23 +1668,13 @@ abstract class BaseRewriting extends BaseObject implements Persistent } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(RewritingTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1603,13 +1682,131 @@ abstract class BaseRewriting extends BaseObject implements Persistent /** * 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) + * @return ChildRewriting The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = RewritingPeer::UPDATED_AT; + $this->modifiedColumns[] = RewritingTableMap::UPDATED_AT; return $this; } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/om/BaseRewritingQuery.php b/core/lib/Thelia/Model/Base/RewritingQuery.php old mode 100755 new mode 100644 similarity index 55% rename from core/lib/Thelia/Model/om/BaseRewritingQuery.php rename to core/lib/Thelia/Model/Base/RewritingQuery.php index 2598ce1f4..bf814cfd2 --- a/core/lib/Thelia/Model/om/BaseRewritingQuery.php +++ b/core/lib/Thelia/Model/Base/RewritingQuery.php @@ -1,118 +1,115 @@ setModelAlias($modelAlias); } @@ -133,21 +130,21 @@ abstract class BaseRewritingQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Rewriting|Rewriting[]|mixed the result, formatted by the current formatter + * @return ChildRewriting|array|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 + if ((null !== ($obj = RewritingTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(RewritingTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -159,46 +156,31 @@ abstract class BaseRewritingQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Rewriting A model object, or null if the key is not found - * @throws PropelException + * @return ChildRewriting A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Rewriting(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildRewriting(); $obj->hydrate($row); - RewritingPeer::addInstanceToPool($obj, (string) $key); + RewritingTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -209,19 +191,19 @@ abstract class BaseRewritingQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Rewriting|Rewriting[]|mixed the result, formatted by the current formatter + * @return ChildRewriting|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -230,22 +212,22 @@ abstract class BaseRewritingQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Rewriting[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -253,12 +235,12 @@ abstract class BaseRewritingQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return RewritingQuery The current query, for fluid interface + * @return ChildRewritingQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(RewritingPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(RewritingTableMap::ID, $key, Criteria::EQUAL); } /** @@ -266,12 +248,12 @@ abstract class BaseRewritingQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return RewritingQuery The current query, for fluid interface + * @return ChildRewritingQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(RewritingPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(RewritingTableMap::ID, $keys, Criteria::IN); } /** @@ -281,8 +263,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -291,18 +272,18 @@ abstract class BaseRewritingQuery extends ModelCriteria * 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 + * @return ChildRewritingQuery 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); + $this->addUsingAlias(RewritingTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(RewritingPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(RewritingTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -313,7 +294,7 @@ abstract class BaseRewritingQuery extends ModelCriteria } } - return $this->addUsingAlias(RewritingPeer::ID, $id, $comparison); + return $this->addUsingAlias(RewritingTableMap::ID, $id, $comparison); } /** @@ -329,7 +310,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * 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 + * @return ChildRewritingQuery The current query, for fluid interface */ public function filterByUrl($url = null, $comparison = null) { @@ -342,7 +323,7 @@ abstract class BaseRewritingQuery extends ModelCriteria } } - return $this->addUsingAlias(RewritingPeer::URL, $url, $comparison); + return $this->addUsingAlias(RewritingTableMap::URL, $url, $comparison); } /** @@ -352,8 +333,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $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 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 * * * @see filterByProduct() @@ -364,18 +344,18 @@ abstract class BaseRewritingQuery extends ModelCriteria * 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 + * @return ChildRewritingQuery 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); + $this->addUsingAlias(RewritingTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($productId['max'])) { - $this->addUsingAlias(RewritingPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(RewritingTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -386,7 +366,7 @@ abstract class BaseRewritingQuery extends ModelCriteria } } - return $this->addUsingAlias(RewritingPeer::PRODUCT_ID, $productId, $comparison); + return $this->addUsingAlias(RewritingTableMap::PRODUCT_ID, $productId, $comparison); } /** @@ -396,8 +376,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $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 + * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id > 12 * * * @see filterByCategory() @@ -408,18 +387,18 @@ abstract class BaseRewritingQuery extends ModelCriteria * 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 + * @return ChildRewritingQuery 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); + $this->addUsingAlias(RewritingTableMap::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($categoryId['max'])) { - $this->addUsingAlias(RewritingPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(RewritingTableMap::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -430,7 +409,7 @@ abstract class BaseRewritingQuery extends ModelCriteria } } - return $this->addUsingAlias(RewritingPeer::CATEGORY_ID, $categoryId, $comparison); + return $this->addUsingAlias(RewritingTableMap::CATEGORY_ID, $categoryId, $comparison); } /** @@ -440,8 +419,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $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 + * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id > 12 * * * @see filterByFolder() @@ -452,18 +430,18 @@ abstract class BaseRewritingQuery extends ModelCriteria * 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 + * @return ChildRewritingQuery 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); + $this->addUsingAlias(RewritingTableMap::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($folderId['max'])) { - $this->addUsingAlias(RewritingPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(RewritingTableMap::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -474,7 +452,7 @@ abstract class BaseRewritingQuery extends ModelCriteria } } - return $this->addUsingAlias(RewritingPeer::FOLDER_ID, $folderId, $comparison); + return $this->addUsingAlias(RewritingTableMap::FOLDER_ID, $folderId, $comparison); } /** @@ -484,8 +462,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * * $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 + * $query->filterByContentId(array('min' => 12)); // WHERE content_id > 12 * * * @see filterByContent() @@ -496,18 +473,18 @@ abstract class BaseRewritingQuery extends ModelCriteria * 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 + * @return ChildRewritingQuery 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); + $this->addUsingAlias(RewritingTableMap::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($contentId['max'])) { - $this->addUsingAlias(RewritingPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(RewritingTableMap::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -518,7 +495,7 @@ abstract class BaseRewritingQuery extends ModelCriteria } } - return $this->addUsingAlias(RewritingPeer::CONTENT_ID, $contentId, $comparison); + return $this->addUsingAlias(RewritingTableMap::CONTENT_ID, $contentId, $comparison); } /** @@ -539,18 +516,18 @@ abstract class BaseRewritingQuery extends ModelCriteria * 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 + * @return ChildRewritingQuery 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); + $this->addUsingAlias(RewritingTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(RewritingPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(RewritingTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -561,7 +538,7 @@ abstract class BaseRewritingQuery extends ModelCriteria } } - return $this->addUsingAlias(RewritingPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(RewritingTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -582,18 +559,18 @@ abstract class BaseRewritingQuery extends ModelCriteria * 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 + * @return ChildRewritingQuery 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); + $this->addUsingAlias(RewritingTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(RewritingPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(RewritingTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -604,32 +581,31 @@ abstract class BaseRewritingQuery extends ModelCriteria } } - return $this->addUsingAlias(RewritingPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(RewritingTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildRewritingQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(RewritingPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(RewritingTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(RewritingPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(RewritingTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -639,7 +615,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * @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 + * @return ChildRewritingQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -668,7 +644,7 @@ abstract class BaseRewritingQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -684,28 +660,27 @@ abstract class BaseRewritingQuery extends ModelCriteria } /** - * Filter the query by a related Category object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Category|ObjectCollection $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. + * @return ChildRewritingQuery The current query, for fluid interface */ public function filterByCategory($category, $comparison = null) { - if ($category instanceof Category) { + if ($category instanceof \Thelia\Model\Category) { return $this - ->addUsingAlias(RewritingPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { + ->addUsingAlias(RewritingTableMap::CATEGORY_ID, $category->getId(), $comparison); + } elseif ($category instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(RewritingPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(RewritingTableMap::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); + throw new PropelException('filterByCategory() only accepts arguments of type \Thelia\Model\Category or Collection'); } } @@ -715,7 +690,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * @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 + * @return ChildRewritingQuery The current query, for fluid interface */ public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -744,7 +719,7 @@ abstract class BaseRewritingQuery extends ModelCriteria /** * Use the Category relation Category object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -760,28 +735,27 @@ abstract class BaseRewritingQuery extends ModelCriteria } /** - * Filter the query by a related Folder object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Folder|ObjectCollection $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. + * @return ChildRewritingQuery The current query, for fluid interface */ public function filterByFolder($folder, $comparison = null) { - if ($folder instanceof Folder) { + if ($folder instanceof \Thelia\Model\Folder) { return $this - ->addUsingAlias(RewritingPeer::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { + ->addUsingAlias(RewritingTableMap::FOLDER_ID, $folder->getId(), $comparison); + } elseif ($folder instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(RewritingPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(RewritingTableMap::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); + throw new PropelException('filterByFolder() only accepts arguments of type \Thelia\Model\Folder or Collection'); } } @@ -791,7 +765,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * @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 + * @return ChildRewritingQuery The current query, for fluid interface */ public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -820,7 +794,7 @@ abstract class BaseRewritingQuery extends ModelCriteria /** * Use the Folder relation Folder object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -836,28 +810,27 @@ abstract class BaseRewritingQuery extends ModelCriteria } /** - * Filter the query by a related Content object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Content|ObjectCollection $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. + * @return ChildRewritingQuery The current query, for fluid interface */ public function filterByContent($content, $comparison = null) { - if ($content instanceof Content) { + if ($content instanceof \Thelia\Model\Content) { return $this - ->addUsingAlias(RewritingPeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { + ->addUsingAlias(RewritingTableMap::CONTENT_ID, $content->getId(), $comparison); + } elseif ($content instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(RewritingPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(RewritingTableMap::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); + throw new PropelException('filterByContent() only accepts arguments of type \Thelia\Model\Content or Collection'); } } @@ -867,7 +840,7 @@ abstract class BaseRewritingQuery extends ModelCriteria * @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 + * @return ChildRewritingQuery The current query, for fluid interface */ public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -896,7 +869,7 @@ abstract class BaseRewritingQuery extends ModelCriteria /** * Use the Content relation Content object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -914,19 +887,94 @@ abstract class BaseRewritingQuery extends ModelCriteria /** * Exclude object from result * - * @param Rewriting $rewriting Object to remove from the list of results + * @param ChildRewriting $rewriting Object to remove from the list of results * - * @return RewritingQuery The current query, for fluid interface + * @return ChildRewritingQuery The current query, for fluid interface */ public function prune($rewriting = null) { if ($rewriting) { - $this->addUsingAlias(RewritingPeer::ID, $rewriting->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(RewritingTableMap::ID, $rewriting->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the rewriting table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + RewritingTableMap::clearInstancePool(); + RewritingTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildRewriting or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildRewriting object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(RewritingTableMap::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(); + + + RewritingTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + RewritingTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -934,31 +982,11 @@ abstract class BaseRewritingQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return RewritingQuery The current query, for fluid interface + * @return ChildRewritingQuery 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); + return $this->addUsingAlias(RewritingTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -966,30 +994,51 @@ abstract class BaseRewritingQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return RewritingQuery The current query, for fluid interface + * @return ChildRewritingQuery 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); + return $this->addUsingAlias(RewritingTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildRewritingQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(RewritingTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildRewritingQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(RewritingTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return RewritingQuery The current query, for fluid interface + * @return ChildRewritingQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(RewritingPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(RewritingTableMap::CREATED_AT); } /** * Order by create date asc * - * @return RewritingQuery The current query, for fluid interface + * @return ChildRewritingQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(RewritingPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(RewritingTableMap::CREATED_AT); } -} + +} // RewritingQuery diff --git a/core/lib/Thelia/Model/Base/Stock.php b/core/lib/Thelia/Model/Base/Stock.php new file mode 100644 index 000000000..6594c845c --- /dev/null +++ b/core/lib/Thelia/Model/Base/Stock.php @@ -0,0 +1,1611 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Stock instance. If + * obj is an instance of Stock, delegates to + * equals(Stock). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Stock The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Stock The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\Stock The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = StockTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [combination_id] column. + * + * @param int $v new value + * @return \Thelia\Model\Stock The current object (for fluent API support) + */ + public function setCombinationId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->combination_id !== $v) { + $this->combination_id = $v; + $this->modifiedColumns[] = StockTableMap::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 \Thelia\Model\Stock The current object (for fluent API support) + */ + public function setProductId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->product_id !== $v) { + $this->product_id = $v; + $this->modifiedColumns[] = StockTableMap::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 \Thelia\Model\Stock The current object (for fluent API support) + */ + public function setIncrease($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->increase !== $v) { + $this->increase = $v; + $this->modifiedColumns[] = StockTableMap::INCREASE; + } + + + return $this; + } // setIncrease() + + /** + * Set the value of [value] column. + * + * @param double $v new value + * @return \Thelia\Model\Stock The current object (for fluent API support) + */ + public function setValue($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = StockTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = StockTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = StockTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : StockTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : StockTableMap::translateFieldName('CombinationId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->combination_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : StockTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->product_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : StockTableMap::translateFieldName('Increase', TableMap::TYPE_PHPNAME, $indexType)]; + $this->increase = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : StockTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $this->value = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : StockTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : StockTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = StockTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\Stock object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(StockTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildStockQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see Stock::setDeleted() + * @see Stock::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildStockQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(StockTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(StockTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(StockTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + StockTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = StockTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . StockTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(StockTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(StockTableMap::COMBINATION_ID)) { + $modifiedColumns[':p' . $index++] = 'COMBINATION_ID'; + } + if ($this->isColumnModified(StockTableMap::PRODUCT_ID)) { + $modifiedColumns[':p' . $index++] = 'PRODUCT_ID'; + } + if ($this->isColumnModified(StockTableMap::INCREASE)) { + $modifiedColumns[':p' . $index++] = 'INCREASE'; + } + if ($this->isColumnModified(StockTableMap::VALUE)) { + $modifiedColumns[':p' . $index++] = 'VALUE'; + } + if ($this->isColumnModified(StockTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(StockTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = StockTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Stock'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Stock'][$this->getPrimaryKey()] = true; + $keys = StockTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = StockTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = StockTableMap::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(StockTableMap::DATABASE_NAME); + + if ($this->isColumnModified(StockTableMap::ID)) $criteria->add(StockTableMap::ID, $this->id); + if ($this->isColumnModified(StockTableMap::COMBINATION_ID)) $criteria->add(StockTableMap::COMBINATION_ID, $this->combination_id); + if ($this->isColumnModified(StockTableMap::PRODUCT_ID)) $criteria->add(StockTableMap::PRODUCT_ID, $this->product_id); + if ($this->isColumnModified(StockTableMap::INCREASE)) $criteria->add(StockTableMap::INCREASE, $this->increase); + if ($this->isColumnModified(StockTableMap::VALUE)) $criteria->add(StockTableMap::VALUE, $this->value); + if ($this->isColumnModified(StockTableMap::CREATED_AT)) $criteria->add(StockTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(StockTableMap::UPDATED_AT)) $criteria->add(StockTableMap::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(StockTableMap::DATABASE_NAME); + $criteria->add(StockTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildCombination object. + * + * @param ChildCombination $v + * @return \Thelia\Model\Stock The current object (for fluent API support) + * @throws PropelException + */ + public function setCombination(ChildCombination $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 ChildCombination object, it will not be re-added. + if ($v !== null) { + $v->addStock($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCombination object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCombination The associated ChildCombination object. + * @throws PropelException + */ + public function getCombination(ConnectionInterface $con = null) + { + if ($this->aCombination === null && ($this->combination_id !== null)) { + $this->aCombination = ChildCombinationQuery::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 ChildProduct object. + * + * @param ChildProduct $v + * @return \Thelia\Model\Stock The current object (for fluent API support) + * @throws PropelException + */ + public function setProduct(ChildProduct $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 ChildProduct object, it will not be re-added. + if ($v !== null) { + $v->addStock($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProduct object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProduct The associated ChildProduct object. + * @throws PropelException + */ + public function getProduct(ConnectionInterface $con = null) + { + if ($this->aProduct === null && ($this->product_id !== null)) { + $this->aProduct = ChildProductQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aCombination = null; + $this->aProduct = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(StockTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildStock The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = StockTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseStockQuery.php b/core/lib/Thelia/Model/Base/StockQuery.php old mode 100755 new mode 100644 similarity index 54% rename from core/lib/Thelia/Model/om/BaseStockQuery.php rename to core/lib/Thelia/Model/Base/StockQuery.php index 792084e78..787543d4b --- a/core/lib/Thelia/Model/om/BaseStockQuery.php +++ b/core/lib/Thelia/Model/Base/StockQuery.php @@ -1,104 +1,103 @@ setModelAlias($modelAlias); } @@ -119,21 +118,21 @@ abstract class BaseStockQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Stock|Stock[]|mixed the result, formatted by the current formatter + * @return ChildStock|array|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 + if ((null !== ($obj = StockTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(StockTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -145,46 +144,31 @@ abstract class BaseStockQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Stock A model object, or null if the key is not found - * @throws PropelException + * @return ChildStock A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `combination_id`, `product_id`, `increase`, `value`, `created_at`, `updated_at` FROM `stock` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Stock(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildStock(); $obj->hydrate($row); - StockPeer::addInstanceToPool($obj, (string) $key); + StockTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -195,19 +179,19 @@ abstract class BaseStockQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Stock|Stock[]|mixed the result, formatted by the current formatter + * @return ChildStock|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -216,22 +200,22 @@ abstract class BaseStockQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Stock[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -239,12 +223,12 @@ abstract class BaseStockQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return StockQuery The current query, for fluid interface + * @return ChildStockQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(StockPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(StockTableMap::ID, $key, Criteria::EQUAL); } /** @@ -252,12 +236,12 @@ abstract class BaseStockQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return StockQuery The current query, for fluid interface + * @return ChildStockQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(StockPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(StockTableMap::ID, $keys, Criteria::IN); } /** @@ -267,8 +251,7 @@ abstract class BaseStockQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -277,18 +260,18 @@ abstract class BaseStockQuery extends ModelCriteria * 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 + * @return ChildStockQuery 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); + $this->addUsingAlias(StockTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(StockPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(StockTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -299,7 +282,7 @@ abstract class BaseStockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockPeer::ID, $id, $comparison); + return $this->addUsingAlias(StockTableMap::ID, $id, $comparison); } /** @@ -309,8 +292,7 @@ abstract class BaseStockQuery extends ModelCriteria * * $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 + * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id > 12 * * * @see filterByCombination() @@ -321,18 +303,18 @@ abstract class BaseStockQuery extends ModelCriteria * 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 + * @return ChildStockQuery 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); + $this->addUsingAlias(StockTableMap::COMBINATION_ID, $combinationId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($combinationId['max'])) { - $this->addUsingAlias(StockPeer::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(StockTableMap::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -343,7 +325,7 @@ abstract class BaseStockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockPeer::COMBINATION_ID, $combinationId, $comparison); + return $this->addUsingAlias(StockTableMap::COMBINATION_ID, $combinationId, $comparison); } /** @@ -353,8 +335,7 @@ abstract class BaseStockQuery extends ModelCriteria * * $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 + * $query->filterByProductId(array('min' => 12)); // WHERE product_id > 12 * * * @see filterByProduct() @@ -365,18 +346,18 @@ abstract class BaseStockQuery extends ModelCriteria * 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 + * @return ChildStockQuery 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); + $this->addUsingAlias(StockTableMap::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($productId['max'])) { - $this->addUsingAlias(StockPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(StockTableMap::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -387,7 +368,7 @@ abstract class BaseStockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockPeer::PRODUCT_ID, $productId, $comparison); + return $this->addUsingAlias(StockTableMap::PRODUCT_ID, $productId, $comparison); } /** @@ -397,8 +378,7 @@ abstract class BaseStockQuery extends ModelCriteria * * $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 + * $query->filterByIncrease(array('min' => 12)); // WHERE increase > 12 * * * @param mixed $increase The value to use as filter. @@ -407,18 +387,18 @@ abstract class BaseStockQuery extends ModelCriteria * 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 + * @return ChildStockQuery 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); + $this->addUsingAlias(StockTableMap::INCREASE, $increase['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($increase['max'])) { - $this->addUsingAlias(StockPeer::INCREASE, $increase['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(StockTableMap::INCREASE, $increase['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -429,7 +409,7 @@ abstract class BaseStockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockPeer::INCREASE, $increase, $comparison); + return $this->addUsingAlias(StockTableMap::INCREASE, $increase, $comparison); } /** @@ -439,8 +419,7 @@ abstract class BaseStockQuery extends ModelCriteria * * $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 + * $query->filterByValue(array('min' => 12)); // WHERE value > 12 * * * @param mixed $value The value to use as filter. @@ -449,18 +428,18 @@ abstract class BaseStockQuery extends ModelCriteria * 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 + * @return ChildStockQuery 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); + $this->addUsingAlias(StockTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($value['max'])) { - $this->addUsingAlias(StockPeer::VALUE, $value['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(StockTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -471,7 +450,7 @@ abstract class BaseStockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockPeer::VALUE, $value, $comparison); + return $this->addUsingAlias(StockTableMap::VALUE, $value, $comparison); } /** @@ -492,18 +471,18 @@ abstract class BaseStockQuery extends ModelCriteria * 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 + * @return ChildStockQuery 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); + $this->addUsingAlias(StockTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(StockPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(StockTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -514,7 +493,7 @@ abstract class BaseStockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(StockTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -535,18 +514,18 @@ abstract class BaseStockQuery extends ModelCriteria * 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 + * @return ChildStockQuery 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); + $this->addUsingAlias(StockTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(StockPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(StockTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -557,32 +536,31 @@ abstract class BaseStockQuery extends ModelCriteria } } - return $this->addUsingAlias(StockPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(StockTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Combination object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Combination|ObjectCollection $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. + * @return ChildStockQuery The current query, for fluid interface */ public function filterByCombination($combination, $comparison = null) { - if ($combination instanceof Combination) { + if ($combination instanceof \Thelia\Model\Combination) { return $this - ->addUsingAlias(StockPeer::COMBINATION_ID, $combination->getId(), $comparison); - } elseif ($combination instanceof PropelObjectCollection) { + ->addUsingAlias(StockTableMap::COMBINATION_ID, $combination->getId(), $comparison); + } elseif ($combination instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(StockPeer::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(StockTableMap::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCombination() only accepts arguments of type Combination or PropelCollection'); + throw new PropelException('filterByCombination() only accepts arguments of type \Thelia\Model\Combination or Collection'); } } @@ -592,7 +570,7 @@ abstract class BaseStockQuery extends ModelCriteria * @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 + * @return ChildStockQuery The current query, for fluid interface */ public function joinCombination($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -621,7 +599,7 @@ abstract class BaseStockQuery extends ModelCriteria /** * Use the Combination relation Combination object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -637,28 +615,27 @@ abstract class BaseStockQuery extends ModelCriteria } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildStockQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(StockPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(StockTableMap::PRODUCT_ID, $product->getId(), $comparison); + } elseif ($product instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(StockPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(StockTableMap::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -668,7 +645,7 @@ abstract class BaseStockQuery extends ModelCriteria * @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 + * @return ChildStockQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) { @@ -697,7 +674,7 @@ abstract class BaseStockQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -715,19 +692,94 @@ abstract class BaseStockQuery extends ModelCriteria /** * Exclude object from result * - * @param Stock $stock Object to remove from the list of results + * @param ChildStock $stock Object to remove from the list of results * - * @return StockQuery The current query, for fluid interface + * @return ChildStockQuery The current query, for fluid interface */ public function prune($stock = null) { if ($stock) { - $this->addUsingAlias(StockPeer::ID, $stock->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(StockTableMap::ID, $stock->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the stock table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + StockTableMap::clearInstancePool(); + StockTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildStock or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildStock object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(StockTableMap::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(); + + + StockTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + StockTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -735,31 +787,11 @@ abstract class BaseStockQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return StockQuery The current query, for fluid interface + * @return ChildStockQuery 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); + return $this->addUsingAlias(StockTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -767,30 +799,51 @@ abstract class BaseStockQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return StockQuery The current query, for fluid interface + * @return ChildStockQuery 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); + return $this->addUsingAlias(StockTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildStockQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(StockTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildStockQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(StockTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return StockQuery The current query, for fluid interface + * @return ChildStockQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(StockPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(StockTableMap::CREATED_AT); } /** * Order by create date asc * - * @return StockQuery The current query, for fluid interface + * @return ChildStockQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(StockPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(StockTableMap::CREATED_AT); } -} + +} // StockQuery diff --git a/core/lib/Thelia/Model/Base/Tax.php b/core/lib/Thelia/Model/Base/Tax.php new file mode 100644 index 000000000..f3717366f --- /dev/null +++ b/core/lib/Thelia/Model/Base/Tax.php @@ -0,0 +1,2067 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Tax instance. If + * obj is an instance of Tax, delegates to + * equals(Tax). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Tax The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Tax The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\Tax The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = TaxTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [rate] column. + * + * @param double $v new value + * @return \Thelia\Model\Tax The current object (for fluent API support) + */ + public function setRate($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->rate !== $v) { + $this->rate = $v; + $this->modifiedColumns[] = TaxTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = TaxTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = TaxTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)]; + $this->rate = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = TaxTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\Tax object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(TaxTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildTaxQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->collTaxRuleCountries = null; + + $this->collTaxI18ns = null; + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see Tax::setDeleted() + * @see Tax::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildTaxQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(TaxTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(TaxTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(TaxTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + TaxTableMap::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 ConnectionInterface $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(ConnectionInterface $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->taxRuleCountriesScheduledForDeletion !== null) { + if (!$this->taxRuleCountriesScheduledForDeletion->isEmpty()) { + foreach ($this->taxRuleCountriesScheduledForDeletion as $taxRuleCountry) { + // need to save related object because we set the relation to null + $taxRuleCountry->save($con); + } + $this->taxRuleCountriesScheduledForDeletion = null; + } + } + + if ($this->collTaxRuleCountries !== null) { + foreach ($this->collTaxRuleCountries as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->taxI18nsScheduledForDeletion !== null) { + if (!$this->taxI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = TaxTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(TaxTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(TaxTableMap::RATE)) { + $modifiedColumns[':p' . $index++] = 'RATE'; + } + if ($this->isColumnModified(TaxTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(TaxTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = TaxTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Tax'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Tax'][$this->getPrimaryKey()] = true; + $keys = TaxTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getRate(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collTaxRuleCountries) { + $result['TaxRuleCountries'] = $this->collTaxRuleCountries->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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = TaxTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = TaxTableMap::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(TaxTableMap::DATABASE_NAME); + + if ($this->isColumnModified(TaxTableMap::ID)) $criteria->add(TaxTableMap::ID, $this->id); + if ($this->isColumnModified(TaxTableMap::RATE)) $criteria->add(TaxTableMap::RATE, $this->rate); + if ($this->isColumnModified(TaxTableMap::CREATED_AT)) $criteria->add(TaxTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(TaxTableMap::UPDATED_AT)) $criteria->add(TaxTableMap::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(TaxTableMap::DATABASE_NAME); + $criteria->add(TaxTableMap::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 \Thelia\Model\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) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getTaxRuleCountries() 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)); + } + } + + } // 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 \Thelia\Model\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; + } + + + /** + * 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) { + return $this->initTaxRuleCountries(); + } + if ('TaxI18n' == $relationName) { + return $this->initTaxI18ns(); + } + } + + /** + * Clears out the collTaxRuleCountries collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addTaxRuleCountries() + */ + public function clearTaxRuleCountries() + { + $this->collTaxRuleCountries = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collTaxRuleCountries collection loaded partially. + */ + public function resetPartialTaxRuleCountries($v = true) + { + $this->collTaxRuleCountriesPartial = $v; + } + + /** + * Initializes the collTaxRuleCountries collection. + * + * By default this just sets the collTaxRuleCountries collection to an empty array (like clearcollTaxRuleCountries()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initTaxRuleCountries($overrideExisting = true) + { + if (null !== $this->collTaxRuleCountries && !$overrideExisting) { + return; + } + $this->collTaxRuleCountries = new ObjectCollection(); + $this->collTaxRuleCountries->setModel('\Thelia\Model\TaxRuleCountry'); + } + + /** + * Gets an array of ChildTaxRuleCountry objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildTax is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects + * @throws PropelException + */ + public function getTaxRuleCountries($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collTaxRuleCountriesPartial && !$this->isNew(); + if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTaxRuleCountries) { + // return empty collection + $this->initTaxRuleCountries(); + } else { + $collTaxRuleCountries = ChildTaxRuleCountryQuery::create(null, $criteria) + ->filterByTax($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collTaxRuleCountriesPartial && count($collTaxRuleCountries)) { + $this->initTaxRuleCountries(false); + + foreach ($collTaxRuleCountries as $obj) { + if (false == $this->collTaxRuleCountries->contains($obj)) { + $this->collTaxRuleCountries->append($obj); + } + } + + $this->collTaxRuleCountriesPartial = true; + } + + $collTaxRuleCountries->getInternalIterator()->rewind(); + + return $collTaxRuleCountries; + } + + if ($partial && $this->collTaxRuleCountries) { + foreach ($this->collTaxRuleCountries as $obj) { + if ($obj->isNew()) { + $collTaxRuleCountries[] = $obj; + } + } + } + + $this->collTaxRuleCountries = $collTaxRuleCountries; + $this->collTaxRuleCountriesPartial = false; + } + } + + return $this->collTaxRuleCountries; + } + + /** + * 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 Collection $taxRuleCountries A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTax The current object (for fluent API support) + */ + public function setTaxRuleCountries(Collection $taxRuleCountries, ConnectionInterface $con = null) + { + $taxRuleCountriesToDelete = $this->getTaxRuleCountries(new Criteria(), $con)->diff($taxRuleCountries); + + + $this->taxRuleCountriesScheduledForDeletion = $taxRuleCountriesToDelete; + + foreach ($taxRuleCountriesToDelete as $taxRuleCountryRemoved) { + $taxRuleCountryRemoved->setTax(null); + } + + $this->collTaxRuleCountries = null; + foreach ($taxRuleCountries as $taxRuleCountry) { + $this->addTaxRuleCountry($taxRuleCountry); + } + + $this->collTaxRuleCountries = $taxRuleCountries; + $this->collTaxRuleCountriesPartial = false; + + return $this; + } + + /** + * Returns the number of related TaxRuleCountry objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related TaxRuleCountry objects. + * @throws PropelException + */ + public function countTaxRuleCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collTaxRuleCountriesPartial && !$this->isNew(); + if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTaxRuleCountries) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getTaxRuleCountries()); + } + + $query = ChildTaxRuleCountryQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTax($this) + ->count($con); + } + + return count($this->collTaxRuleCountries); + } + + /** + * Method called to associate a ChildTaxRuleCountry object to this object + * through the ChildTaxRuleCountry foreign key attribute. + * + * @param ChildTaxRuleCountry $l ChildTaxRuleCountry + * @return \Thelia\Model\Tax The current object (for fluent API support) + */ + public function addTaxRuleCountry(ChildTaxRuleCountry $l) + { + if ($this->collTaxRuleCountries === null) { + $this->initTaxRuleCountries(); + $this->collTaxRuleCountriesPartial = true; + } + + if (!in_array($l, $this->collTaxRuleCountries->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->collTaxRuleCountries[]= $taxRuleCountry; + $taxRuleCountry->setTax($this); + } + + /** + * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. + * @return ChildTax The current object (for fluent API support) + */ + public function removeTaxRuleCountry($taxRuleCountry) + { + if ($this->getTaxRuleCountries()->contains($taxRuleCountry)) { + $this->collTaxRuleCountries->remove($this->collTaxRuleCountries->search($taxRuleCountry)); + if (null === $this->taxRuleCountriesScheduledForDeletion) { + $this->taxRuleCountriesScheduledForDeletion = clone $this->collTaxRuleCountries; + $this->taxRuleCountriesScheduledForDeletion->clear(); + } + $this->taxRuleCountriesScheduledForDeletion[]= $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 TaxRuleCountries from storage. + * + * This 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 ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects + */ + public function getTaxRuleCountriesJoinTaxRule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildTaxRuleCountryQuery::create(null, $criteria); + $query->joinWith('TaxRule', $joinBehavior); + + return $this->getTaxRuleCountries($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 TaxRuleCountries from storage. + * + * This 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 ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects + */ + public function getTaxRuleCountriesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildTaxRuleCountryQuery::create(null, $criteria); + $query->joinWith('Country', $joinBehavior); + + return $this->getTaxRuleCountries($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 void + * @see addTaxI18ns() + */ + public function clearTaxI18ns() + { + $this->collTaxI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collTaxI18ns collection loaded partially. + */ + 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 ObjectCollection(); + $this->collTaxI18ns->setModel('\Thelia\Model\TaxI18n'); + } + + /** + * Gets an array of ChildTaxI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildTax is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildTaxI18n[] List of ChildTaxI18n objects + * @throws PropelException + */ + public function getTaxI18ns($criteria = null, ConnectionInterface $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 = ChildTaxI18nQuery::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 Collection $taxI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTax The current object (for fluent API support) + */ + public function setTaxI18ns(Collection $taxI18ns, ConnectionInterface $con = null) + { + $taxI18nsToDelete = $this->getTaxI18ns(new Criteria(), $con)->diff($taxI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->taxI18nsScheduledForDeletion = clone $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 ConnectionInterface $con + * @return int Count of related TaxI18n objects. + * @throws PropelException + */ + public function countTaxI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $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 = ChildTaxI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByTax($this) + ->count($con); + } + + return count($this->collTaxI18ns); + } + + /** + * Method called to associate a ChildTaxI18n object to this object + * through the ChildTaxI18n foreign key attribute. + * + * @param ChildTaxI18n $l ChildTaxI18n + * @return \Thelia\Model\Tax The current object (for fluent API support) + */ + public function addTaxI18n(ChildTaxI18n $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 ChildTax 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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collTaxRuleCountries) { + foreach ($this->collTaxRuleCountries as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collTaxI18ns) { + foreach ($this->collTaxI18ns as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_EN'; + $this->currentTranslations = null; + + if ($this->collTaxRuleCountries instanceof Collection) { + $this->collTaxRuleCountries->clearIterator(); + } + $this->collTaxRuleCountries = null; + if ($this->collTaxI18ns instanceof Collection) { + $this->collTaxI18ns->clearIterator(); + } + $this->collTaxI18ns = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(TaxTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildTax The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = TaxTableMap::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 ChildTax The current object (for fluent API support) + */ + public function setLocale($locale = 'en_EN') + { + $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 ConnectionInterface $con an optional connection object + * + * @return ChildTaxI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $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 ChildTaxI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildTaxI18nQuery::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 ConnectionInterface $con an optional connection object + * + * @return ChildTax The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildTaxI18nQuery::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 ConnectionInterface $con an optional connection object + * + * @return ChildTaxI18n */ + public function getCurrentTranslation(ConnectionInterface $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 \Thelia\Model\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 \Thelia\Model\TaxI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/TaxI18n.php b/core/lib/Thelia/Model/Base/TaxI18n.php new file mode 100644 index 000000000..8fdec086d --- /dev/null +++ b/core/lib/Thelia/Model/Base/TaxI18n.php @@ -0,0 +1,1323 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\TaxI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another TaxI18n instance. If + * obj is an instance of TaxI18n, delegates to + * equals(TaxI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return TaxI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return TaxI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\TaxI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = TaxI18nTableMap::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 \Thelia\Model\TaxI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = TaxI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\TaxI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = TaxI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\TaxI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = TaxI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = TaxI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\TaxI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(TaxI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildTaxI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aTax = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see TaxI18n::setDeleted() + * @see TaxI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildTaxI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME); + } + + $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); + TaxI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(TaxI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(TaxI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(TaxI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(TaxI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = TaxI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['TaxI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['TaxI18n'][serialize($this->getPrimaryKey())] = true; + $keys = TaxI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = TaxI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = TaxI18nTableMap::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(TaxI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(TaxI18nTableMap::ID)) $criteria->add(TaxI18nTableMap::ID, $this->id); + if ($this->isColumnModified(TaxI18nTableMap::LOCALE)) $criteria->add(TaxI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(TaxI18nTableMap::TITLE)) $criteria->add(TaxI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(TaxI18nTableMap::DESCRIPTION)) $criteria->add(TaxI18nTableMap::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(TaxI18nTableMap::DATABASE_NAME); + $criteria->add(TaxI18nTableMap::ID, $this->id); + $criteria->add(TaxI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildTax object. + * + * @param ChildTax $v + * @return \Thelia\Model\TaxI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setTax(ChildTax $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 ChildTax object, it will not be re-added. + if ($v !== null) { + $v->addTaxI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildTax object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildTax The associated ChildTax object. + * @throws PropelException + */ + public function getTax(ConnectionInterface $con = null) + { + if ($this->aTax === null && ($this->id !== null)) { + $this->aTax = ChildTaxQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aTax = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(TaxI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseTaxI18nQuery.php b/core/lib/Thelia/Model/Base/TaxI18nQuery.php old mode 100755 new mode 100644 similarity index 50% rename from core/lib/Thelia/Model/om/BaseTaxI18nQuery.php rename to core/lib/Thelia/Model/Base/TaxI18nQuery.php index 6d41da4e4..e23b36155 --- a/core/lib/Thelia/Model/om/BaseTaxI18nQuery.php +++ b/core/lib/Thelia/Model/Base/TaxI18nQuery.php @@ -1,88 +1,87 @@ setModelAlias($modelAlias); } @@ -102,23 +101,22 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * $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 + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object * - * @return TaxI18n|TaxI18n[]|mixed the result, formatted by the current formatter + * @return ChildTaxI18n|array|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 + if ((null !== ($obj = TaxI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(TaxI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(TaxI18nTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -135,14 +133,13 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * 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 + * @param ConnectionInterface $con A connection object * - * @return TaxI18n A model object, or null if the key is not found - * @throws PropelException + * @return ChildTaxI18n A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `locale`, `title`, `description` FROM `tax_i18n` WHERE `id` = :p0 AND `locale` = :p1'; + $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); @@ -150,13 +147,13 @@ abstract class BaseTaxI18nQuery extends ModelCriteria $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new TaxI18n(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildTaxI18n(); $obj->hydrate($row); - TaxI18nPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + TaxI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); } $stmt->closeCursor(); @@ -167,19 +164,19 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return TaxI18n|TaxI18n[]|mixed the result, formatted by the current formatter + * @return ChildTaxI18n|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -188,22 +185,22 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|TaxI18n[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -211,12 +208,12 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return TaxI18nQuery The current query, for fluid interface + * @return ChildTaxI18nQuery 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); + $this->addUsingAlias(TaxI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(TaxI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); return $this; } @@ -226,7 +223,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return TaxI18nQuery The current query, for fluid interface + * @return ChildTaxI18nQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { @@ -234,8 +231,8 @@ abstract class BaseTaxI18nQuery extends ModelCriteria 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 = $this->getNewCriterion(TaxI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(TaxI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); $cton0->addAnd($cton1); $this->addOr($cton0); } @@ -250,8 +247,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @see filterByTax() @@ -262,18 +258,18 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * 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 + * @return ChildTaxI18nQuery 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); + $this->addUsingAlias(TaxI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(TaxI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -284,7 +280,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxI18nPeer::ID, $id, $comparison); + return $this->addUsingAlias(TaxI18nTableMap::ID, $id, $comparison); } /** @@ -300,7 +296,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * 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 + * @return ChildTaxI18nQuery The current query, for fluid interface */ public function filterByLocale($locale = null, $comparison = null) { @@ -313,7 +309,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxI18nPeer::LOCALE, $locale, $comparison); + return $this->addUsingAlias(TaxI18nTableMap::LOCALE, $locale, $comparison); } /** @@ -329,7 +325,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * 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 + * @return ChildTaxI18nQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -342,7 +338,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxI18nPeer::TITLE, $title, $comparison); + return $this->addUsingAlias(TaxI18nTableMap::TITLE, $title, $comparison); } /** @@ -358,7 +354,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * 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 + * @return ChildTaxI18nQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -371,32 +367,31 @@ abstract class BaseTaxI18nQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxI18nPeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(TaxI18nTableMap::DESCRIPTION, $description, $comparison); } /** - * Filter the query by a related Tax object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Tax|ObjectCollection $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. + * @return ChildTaxI18nQuery The current query, for fluid interface */ public function filterByTax($tax, $comparison = null) { - if ($tax instanceof Tax) { + if ($tax instanceof \Thelia\Model\Tax) { return $this - ->addUsingAlias(TaxI18nPeer::ID, $tax->getId(), $comparison); - } elseif ($tax instanceof PropelObjectCollection) { + ->addUsingAlias(TaxI18nTableMap::ID, $tax->getId(), $comparison); + } elseif ($tax instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(TaxI18nPeer::ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(TaxI18nTableMap::ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection'); + throw new PropelException('filterByTax() only accepts arguments of type \Thelia\Model\Tax or Collection'); } } @@ -406,7 +401,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria * @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 + * @return ChildTaxI18nQuery The current query, for fluid interface */ public function joinTax($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -435,7 +430,7 @@ abstract class BaseTaxI18nQuery extends ModelCriteria /** * Use the Tax relation Tax object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -453,19 +448,94 @@ abstract class BaseTaxI18nQuery extends ModelCriteria /** * Exclude object from result * - * @param TaxI18n $taxI18n Object to remove from the list of results + * @param ChildTaxI18n $taxI18n Object to remove from the list of results * - * @return TaxI18nQuery The current query, for fluid interface + * @return ChildTaxI18nQuery 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->addCond('pruneCond0', $this->getAliasedColName(TaxI18nTableMap::ID), $taxI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(TaxI18nTableMap::LOCALE), $taxI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; } -} + /** + * Deletes all rows from the tax_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + TaxI18nTableMap::clearInstancePool(); + TaxI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildTaxI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildTaxI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(TaxI18nTableMap::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(); + + + TaxI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + TaxI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // TaxI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseTaxQuery.php b/core/lib/Thelia/Model/Base/TaxQuery.php old mode 100755 new mode 100644 similarity index 56% rename from core/lib/Thelia/Model/om/BaseTaxQuery.php rename to core/lib/Thelia/Model/Base/TaxQuery.php index 5149f7e81..0a61cbb3c --- a/core/lib/Thelia/Model/om/BaseTaxQuery.php +++ b/core/lib/Thelia/Model/Base/TaxQuery.php @@ -1,92 +1,92 @@ setModelAlias($modelAlias); } @@ -107,21 +107,21 @@ abstract class BaseTaxQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return Tax|Tax[]|mixed the result, formatted by the current formatter + * @return ChildTax|array|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 + if ((null !== ($obj = TaxTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(TaxTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -133,46 +133,31 @@ abstract class BaseTaxQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return Tax A model object, or null if the key is not found - * @throws PropelException + * @return ChildTax A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `rate`, `created_at`, `updated_at` FROM `tax` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Tax(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildTax(); $obj->hydrate($row); - TaxPeer::addInstanceToPool($obj, (string) $key); + TaxTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -183,19 +168,19 @@ abstract class BaseTaxQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return Tax|Tax[]|mixed the result, formatted by the current formatter + * @return ChildTax|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -204,22 +189,22 @@ abstract class BaseTaxQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|Tax[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -227,12 +212,12 @@ abstract class BaseTaxQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return TaxQuery The current query, for fluid interface + * @return ChildTaxQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(TaxPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(TaxTableMap::ID, $key, Criteria::EQUAL); } /** @@ -240,12 +225,12 @@ abstract class BaseTaxQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return TaxQuery The current query, for fluid interface + * @return ChildTaxQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(TaxPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(TaxTableMap::ID, $keys, Criteria::IN); } /** @@ -255,8 +240,7 @@ abstract class BaseTaxQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -265,18 +249,18 @@ abstract class BaseTaxQuery extends ModelCriteria * 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 + * @return ChildTaxQuery 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); + $this->addUsingAlias(TaxTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(TaxPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -287,7 +271,7 @@ abstract class BaseTaxQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxPeer::ID, $id, $comparison); + return $this->addUsingAlias(TaxTableMap::ID, $id, $comparison); } /** @@ -297,8 +281,7 @@ abstract class BaseTaxQuery extends ModelCriteria * * $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 + * $query->filterByRate(array('min' => 12)); // WHERE rate > 12 * * * @param mixed $rate The value to use as filter. @@ -307,18 +290,18 @@ abstract class BaseTaxQuery extends ModelCriteria * 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 + * @return ChildTaxQuery 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); + $this->addUsingAlias(TaxTableMap::RATE, $rate['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($rate['max'])) { - $this->addUsingAlias(TaxPeer::RATE, $rate['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxTableMap::RATE, $rate['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -329,7 +312,7 @@ abstract class BaseTaxQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxPeer::RATE, $rate, $comparison); + return $this->addUsingAlias(TaxTableMap::RATE, $rate, $comparison); } /** @@ -350,18 +333,18 @@ abstract class BaseTaxQuery extends ModelCriteria * 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 + * @return ChildTaxQuery 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); + $this->addUsingAlias(TaxTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(TaxPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -372,7 +355,7 @@ abstract class BaseTaxQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(TaxTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -393,18 +376,18 @@ abstract class BaseTaxQuery extends ModelCriteria * 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 + * @return ChildTaxQuery 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); + $this->addUsingAlias(TaxTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(TaxPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -415,30 +398,29 @@ abstract class BaseTaxQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(TaxTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related TaxRuleCountry object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\TaxRuleCountry|ObjectCollection $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. + * @return ChildTaxQuery The current query, for fluid interface */ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) { - if ($taxRuleCountry instanceof TaxRuleCountry) { + if ($taxRuleCountry instanceof \Thelia\Model\TaxRuleCountry) { return $this - ->addUsingAlias(TaxPeer::ID, $taxRuleCountry->getTaxId(), $comparison); - } elseif ($taxRuleCountry instanceof PropelObjectCollection) { + ->addUsingAlias(TaxTableMap::ID, $taxRuleCountry->getTaxId(), $comparison); + } elseif ($taxRuleCountry instanceof ObjectCollection) { return $this ->useTaxRuleCountryQuery() ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection'); + throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type \Thelia\Model\TaxRuleCountry or Collection'); } } @@ -448,7 +430,7 @@ abstract class BaseTaxQuery extends ModelCriteria * @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 + * @return ChildTaxQuery The current query, for fluid interface */ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -477,7 +459,7 @@ abstract class BaseTaxQuery extends ModelCriteria /** * Use the TaxRuleCountry relation TaxRuleCountry object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -493,26 +475,25 @@ abstract class BaseTaxQuery extends ModelCriteria } /** - * Filter the query by a related TaxI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\TaxI18n|ObjectCollection $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. + * @return ChildTaxQuery The current query, for fluid interface */ public function filterByTaxI18n($taxI18n, $comparison = null) { - if ($taxI18n instanceof TaxI18n) { + if ($taxI18n instanceof \Thelia\Model\TaxI18n) { return $this - ->addUsingAlias(TaxPeer::ID, $taxI18n->getId(), $comparison); - } elseif ($taxI18n instanceof PropelObjectCollection) { + ->addUsingAlias(TaxTableMap::ID, $taxI18n->getId(), $comparison); + } elseif ($taxI18n instanceof ObjectCollection) { return $this ->useTaxI18nQuery() ->filterByPrimaryKeys($taxI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByTaxI18n() only accepts arguments of type TaxI18n or PropelCollection'); + throw new PropelException('filterByTaxI18n() only accepts arguments of type \Thelia\Model\TaxI18n or Collection'); } } @@ -522,7 +503,7 @@ abstract class BaseTaxQuery extends ModelCriteria * @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 + * @return ChildTaxQuery The current query, for fluid interface */ public function joinTaxI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -551,7 +532,7 @@ abstract class BaseTaxQuery extends ModelCriteria /** * Use the TaxI18n relation TaxI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -569,19 +550,94 @@ abstract class BaseTaxQuery extends ModelCriteria /** * Exclude object from result * - * @param Tax $tax Object to remove from the list of results + * @param ChildTax $tax Object to remove from the list of results * - * @return TaxQuery The current query, for fluid interface + * @return ChildTaxQuery The current query, for fluid interface */ public function prune($tax = null) { if ($tax) { - $this->addUsingAlias(TaxPeer::ID, $tax->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(TaxTableMap::ID, $tax->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the tax table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + TaxTableMap::clearInstancePool(); + TaxTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildTax or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildTax object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(TaxTableMap::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(); + + + TaxTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + TaxTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -589,31 +645,11 @@ abstract class BaseTaxQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return TaxQuery The current query, for fluid interface + * @return ChildTaxQuery 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); + return $this->addUsingAlias(TaxTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -621,32 +657,53 @@ abstract class BaseTaxQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return TaxQuery The current query, for fluid interface + * @return ChildTaxQuery 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); + return $this->addUsingAlias(TaxTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildTaxQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(TaxTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildTaxQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(TaxTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return TaxQuery The current query, for fluid interface + * @return ChildTaxQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(TaxPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(TaxTableMap::CREATED_AT); } /** * Order by create date asc * - * @return TaxQuery The current query, for fluid interface + * @return ChildTaxQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(TaxPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(TaxTableMap::CREATED_AT); } + // i18n behavior /** @@ -656,9 +713,9 @@ abstract class BaseTaxQuery extends ModelCriteria * @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 + * @return ChildTaxQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxI18n'; @@ -674,9 +731,9 @@ abstract class BaseTaxQuery extends ModelCriteria * @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 + * @return ChildTaxQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -695,13 +752,13 @@ abstract class BaseTaxQuery extends ModelCriteria * @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 + * @return ChildTaxI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxI18n', 'Thelia\Model\TaxI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'TaxI18n', '\Thelia\Model\TaxI18nQuery'); } -} +} // TaxQuery diff --git a/core/lib/Thelia/Model/om/BaseTaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php old mode 100755 new mode 100644 similarity index 51% rename from core/lib/Thelia/Model/om/BaseTaxRule.php rename to core/lib/Thelia/Model/Base/TaxRule.php index 5c86263c1..101471313 --- a/core/lib/Thelia/Model/om/BaseTaxRule.php +++ b/core/lib/Thelia/Model/Base/TaxRule.php @@ -1,57 +1,65 @@ modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another TaxRule instance. If + * obj is an instance of TaxRule, delegates to + * equals(TaxRule). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return TaxRule The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return TaxRule The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + /** * Get the [id] column value. * - * @return int + * @return int */ public function getId() { + return $this->id; } /** * Get the [code] column value. * - * @return string + * @return string */ public function getCode() { + return $this->code; } /** * Get the [title] column value. * - * @return string + * @return string */ public function getTitle() { + return $this->title; } /** * Get the [description] column value. * - * @return string + * @return string */ public function getDescription() { + return $this->description; } @@ -203,97 +457,57 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getCreatedAt($format = NULL) { - 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; + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; } - - 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 + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 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') + public function getUpdatedAt($format = NULL) { - 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; + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; } - - 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) + * @param int $v new value + * @return \Thelia\Model\TaxRule The current object (for fluent API support) */ public function setId($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = TaxRulePeer::ID; + $this->modifiedColumns[] = TaxRuleTableMap::ID; } @@ -303,18 +517,18 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Set the value of [code] column. * - * @param string $v new value - * @return TaxRule The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\TaxRule The current object (for fluent API support) */ public function setCode($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->code !== $v) { $this->code = $v; - $this->modifiedColumns[] = TaxRulePeer::CODE; + $this->modifiedColumns[] = TaxRuleTableMap::CODE; } @@ -324,18 +538,18 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Set the value of [title] column. * - * @param string $v new value - * @return TaxRule The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\TaxRule The current object (for fluent API support) */ public function setTitle($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->title !== $v) { $this->title = $v; - $this->modifiedColumns[] = TaxRulePeer::TITLE; + $this->modifiedColumns[] = TaxRuleTableMap::TITLE; } @@ -345,18 +559,18 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Set the value of [description] column. * - * @param string $v new value - * @return TaxRule The current object (for fluent API support) + * @param string $v new value + * @return \Thelia\Model\TaxRule The current object (for fluent API support) */ public function setDescription($v) { - if ($v !== null && is_numeric($v)) { + if ($v !== null) { $v = (string) $v; } if ($this->description !== $v) { $this->description = $v; - $this->modifiedColumns[] = TaxRulePeer::DESCRIPTION; + $this->modifiedColumns[] = TaxRuleTableMap::DESCRIPTION; } @@ -366,19 +580,17 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\TaxRule The current object (for fluent API support) */ public function setCreatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = TaxRuleTableMap::CREATED_AT; } } // if either are not null @@ -389,19 +601,17 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * 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) + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\TaxRule The current object (for fluent API support) */ public function setUpdatedAt($v) { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); + $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 ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = TaxRuleTableMap::UPDATED_AT; } } // if either are not null @@ -419,7 +629,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { - // otherwise, everything was equal, so return true + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -431,22 +641,44 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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 array $row The row returned by DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * * @return int next starting column * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. */ - public function hydrate($row, $startcol = 0, $rehydrate = false) + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { 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; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxRuleTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : TaxRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $this->resetModified(); $this->setNew(false); @@ -454,11 +686,11 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if ($rehydrate) { $this->ensureConsistency(); } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = TaxRulePeer::NUM_HYDRATE_COLUMNS. + + return $startcol + 6; // 6 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating TaxRule object", $e); + throw new PropelException("Error populating \Thelia\Model\TaxRule object", 0, $e); } } @@ -477,7 +709,6 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ public function ensureConsistency() { - } // ensureConsistency /** @@ -485,12 +716,12 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * * 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. + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface 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) + public function reload($deep = false, ConnectionInterface $con = null) { if ($this->isDeleted()) { throw new PropelException("Cannot reload a deleted object."); @@ -501,25 +732,25 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(TaxRuleTableMap::DATABASE_NAME); } // 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(); + $dataFetcher = ChildTaxRuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); if (!$row) { throw new PropelException('Cannot find matching row in the database to reload object values.'); } - $this->hydrate($row, 0, true); // rehydrate + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate if ($deep) { // also de-associate any related objects? $this->collProducts = null; - $this->collTaxRuleCountrys = null; + $this->collTaxRuleCountries = null; $this->collTaxRuleI18ns = null; @@ -529,26 +760,25 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Removes this object from datastore and sets delete attribute. * - * @param PropelPDO $con + * @param ConnectionInterface $con * @return void * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() + * @see TaxRule::setDeleted() + * @see TaxRule::isDeleted() */ - public function delete(PropelPDO $con = null) + public function delete(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = TaxRuleQuery::create() + $deleteQuery = ChildTaxRuleQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -573,20 +803,19 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * method. This method wraps all precipitate database operations in a * single transaction. * - * @param PropelPDO $con + * @param ConnectionInterface $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() + * @see doSave() */ - public function save(PropelPDO $con = null) + public function save(ConnectionInterface $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 = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -596,16 +825,16 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(TaxRulePeer::CREATED_AT)) { + if (!$this->isColumnModified(TaxRuleTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(TaxRulePeer::UPDATED_AT)) { + if (!$this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(TaxRulePeer::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -617,7 +846,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->postUpdate($con); } $this->postSave($con); - TaxRulePeer::addInstanceToPool($this); + TaxRuleTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -636,12 +865,12 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException - * @see save() + * @see save() */ - protected function doSave(PropelPDO $con) + protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { @@ -668,26 +897,25 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } } - if ($this->collProducts !== null) { - foreach ($this->collProducts as $referrerFK) { + 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->taxRuleCountriesScheduledForDeletion !== null) { + if (!$this->taxRuleCountriesScheduledForDeletion->isEmpty()) { + \Thelia\Model\TaxRuleCountryQuery::create() + ->filterByPrimaryKeys($this->taxRuleCountriesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->taxRuleCountriesScheduledForDeletion = null; } } - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { + if ($this->collTaxRuleCountries !== null) { + foreach ($this->collTaxRuleCountries as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -696,15 +924,15 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if ($this->taxRuleI18nsScheduledForDeletion !== null) { if (!$this->taxRuleI18nsScheduledForDeletion->isEmpty()) { - TaxRuleI18nQuery::create() + \Thelia\Model\TaxRuleI18nQuery::create() ->filterByPrimaryKeys($this->taxRuleI18nsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->taxRuleI18nsScheduledForDeletion = null; } } - if ($this->collTaxRuleI18ns !== null) { - foreach ($this->collTaxRuleI18ns as $referrerFK) { + if ($this->collTaxRuleI18ns !== null) { + foreach ($this->collTaxRuleI18ns as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -721,43 +949,43 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Insert the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * * @throws PropelException - * @see doSave() + * @see doSave() */ - protected function doInsert(PropelPDO $con) + protected function doInsert(ConnectionInterface $con) { $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = TaxRulePeer::ID; + $this->modifiedColumns[] = TaxRuleTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxRulePeer::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxRuleTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(TaxRulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; + if ($this->isColumnModified(TaxRuleTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(TaxRulePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; + if ($this->isColumnModified(TaxRuleTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; } - if ($this->isColumnModified(TaxRulePeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; + if ($this->isColumnModified(TaxRuleTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; } - if ($this->isColumnModified(TaxRulePeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; + if ($this->isColumnModified(TaxRuleTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; } - if ($this->isColumnModified(TaxRulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; + if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(TaxRulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; + if ($this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO `tax_rule` (%s) VALUES (%s)', + 'INSERT INTO tax_rule (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -766,36 +994,36 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { - case '`id`': + case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case '`code`': + case 'CODE': $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); break; - case '`title`': + case 'TITLE': $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); break; - case '`description`': + case 'DESCRIPTION': $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); + throw new PropelException('Unable to get autoincrement id.', 0, $e); } $this->setId($pk); @@ -805,128 +1033,32 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Update the row in the database. * - * @param PropelPDO $con + * @param ConnectionInterface $con * - * @see doSave() + * @return Integer Number of updated rows + * @see doSave() */ - protected function doUpdate(PropelPDO $con) + protected function doUpdate(ConnectionInterface $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); + return $selectCriteria->doUpdate($valuesCriteria, $con); } /** * 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 + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return mixed Value of field. */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = TaxRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = TaxRuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -936,7 +1068,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * Retrieves a field from the object by Position as specified in the xml schema. * Zero-based. * - * @param int $pos position in xml schema + * @param int $pos position in xml schema * @return mixed Value of field at $pos */ public function getByPosition($pos) @@ -972,22 +1104,22 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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 string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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) + public function toArray($keyType = TableMap::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); + $keys = TaxRuleTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getCode(), @@ -996,12 +1128,18 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $keys[4] => $this->getCreatedAt(), $keys[5] => $this->getUpdatedAt(), ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + 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->collTaxRuleCountries) { + $result['TaxRuleCountries'] = $this->collTaxRuleCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collTaxRuleI18ns) { $result['TaxRuleI18ns'] = $this->collTaxRuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1014,27 +1152,27 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * 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 + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. * @return void */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = TaxRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + $pos = TaxRuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $this->setByPosition($pos, $value); + return $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 + * @param int $pos position in xml schema + * @param mixed $value field value * @return void */ public function setByPosition($pos, $value) @@ -1070,17 +1208,17 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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 + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. + * @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) + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = TaxRulePeer::getFieldNames($keyType); + $keys = TaxRuleTableMap::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]]); @@ -1097,14 +1235,14 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ public function buildCriteria() { - $criteria = new Criteria(TaxRulePeer::DATABASE_NAME); + $criteria = new Criteria(TaxRuleTableMap::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); + if ($this->isColumnModified(TaxRuleTableMap::ID)) $criteria->add(TaxRuleTableMap::ID, $this->id); + if ($this->isColumnModified(TaxRuleTableMap::CODE)) $criteria->add(TaxRuleTableMap::CODE, $this->code); + if ($this->isColumnModified(TaxRuleTableMap::TITLE)) $criteria->add(TaxRuleTableMap::TITLE, $this->title); + if ($this->isColumnModified(TaxRuleTableMap::DESCRIPTION)) $criteria->add(TaxRuleTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) $criteria->add(TaxRuleTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) $criteria->add(TaxRuleTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1119,15 +1257,15 @@ abstract class BaseTaxRule extends BaseObject implements Persistent */ public function buildPkeyCriteria() { - $criteria = new Criteria(TaxRulePeer::DATABASE_NAME); - $criteria->add(TaxRulePeer::ID, $this->id); + $criteria = new Criteria(TaxRuleTableMap::DATABASE_NAME); + $criteria->add(TaxRuleTableMap::ID, $this->id); return $criteria; } /** * Returns the primary key for this object (row). - * @return int + * @return int */ public function getPrimaryKey() { @@ -1137,7 +1275,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Generic method to set the primary key (id column). * - * @param int $key Primary key. + * @param int $key Primary key. * @return void */ public function setPrimaryKey($key) @@ -1161,9 +1299,9 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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. + * @param object $copyObj An object of \Thelia\Model\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) @@ -1174,12 +1312,10 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($deepCopy && !$this->startCopy) { + if ($deepCopy) { // 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 @@ -1187,7 +1323,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } } - foreach ($this->getTaxRuleCountrys() as $relObj) { + foreach ($this->getTaxRuleCountries() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addTaxRuleCountry($relObj->copy($deepCopy)); } @@ -1199,8 +1335,6 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } } - //unflag object copy - $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { @@ -1217,8 +1351,8 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\TaxRule Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1231,43 +1365,25 @@ abstract class BaseTaxRule extends BaseObject implements Persistent 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 + * @param string $relationName The name of the relation to initialize * @return void */ public function initRelation($relationName) { if ('Product' == $relationName) { - $this->initProducts(); + return $this->initProducts(); } if ('TaxRuleCountry' == $relationName) { - $this->initTaxRuleCountrys(); + return $this->initTaxRuleCountries(); } if ('TaxRuleI18n' == $relationName) { - $this->initTaxRuleI18ns(); + return $this->initTaxRuleI18ns(); } } @@ -1277,21 +1393,16 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * This 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) + * @return void * @see addProducts() */ public function clearProducts() { - $this->collProducts = null; // important to set this to null since that means it is uninitialized - $this->collProductsPartial = null; - - return $this; + $this->collProducts = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collProducts collection loaded partially - * - * @return void + * Reset is the collProducts collection loaded partially. */ public function resetPartialProducts($v = true) { @@ -1305,7 +1416,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1315,25 +1426,25 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if (null !== $this->collProducts && !$overrideExisting) { return; } - $this->collProducts = new PropelObjectCollection(); - $this->collProducts->setModel('Product'); + $this->collProducts = new ObjectCollection(); + $this->collProducts->setModel('\Thelia\Model\Product'); } /** - * Gets an array of Product objects which contain a foreign key that references this object. + * Gets an array of ChildProduct objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildTaxRule is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProduct[] List of ChildProduct objects * @throws PropelException */ - public function getProducts($criteria = null, PropelPDO $con = null) + public function getProducts($criteria = null, ConnectionInterface $con = null) { $partial = $this->collProductsPartial && !$this->isNew(); if (null === $this->collProducts || null !== $criteria || $partial) { @@ -1341,29 +1452,31 @@ abstract class BaseTaxRule extends BaseObject implements Persistent // return empty collection $this->initProducts(); } else { - $collProducts = ProductQuery::create(null, $criteria) + $collProducts = ChildProductQuery::create(null, $criteria) ->filterByTaxRule($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collProductsPartial && count($collProducts)) { - $this->initProducts(false); + $this->initProducts(false); - foreach($collProducts as $obj) { - if (false == $this->collProducts->contains($obj)) { - $this->collProducts->append($obj); + foreach ($collProducts as $obj) { + if (false == $this->collProducts->contains($obj)) { + $this->collProducts->append($obj); + } } - } - $this->collProductsPartial = true; + $this->collProductsPartial = true; } $collProducts->getInternalIterator()->rewind(); + return $collProducts; } - if($partial && $this->collProducts) { - foreach($this->collProducts as $obj) { - if($obj->isNew()) { + if ($partial && $this->collProducts) { + foreach ($this->collProducts as $obj) { + if ($obj->isNew()) { $collProducts[] = $obj; } } @@ -1383,15 +1496,16 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * It will 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) + * @param Collection $products A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTaxRule The current object (for fluent API support) */ - public function setProducts(PropelCollection $products, PropelPDO $con = null) + public function setProducts(Collection $products, ConnectionInterface $con = null) { $productsToDelete = $this->getProducts(new Criteria(), $con)->diff($products); - $this->productsScheduledForDeletion = unserialize(serialize($productsToDelete)); + + $this->productsScheduledForDeletion = $productsToDelete; foreach ($productsToDelete as $productRemoved) { $productRemoved->setTaxRule(null); @@ -1411,13 +1525,13 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Returns the number of related Product objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related Product objects. * @throws PropelException */ - public function countProducts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countProducts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collProductsPartial && !$this->isNew(); if (null === $this->collProducts || null !== $criteria || $partial) { @@ -1425,10 +1539,11 @@ abstract class BaseTaxRule extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getProducts()); } - $query = ProductQuery::create(null, $criteria); + + $query = ChildProductQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1442,18 +1557,19 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } /** - * Method called to associate a Product object to this object - * through the Product foreign key attribute. + * Method called to associate a ChildProduct object to this object + * through the ChildProduct foreign key attribute. * - * @param Product $l Product - * @return TaxRule The current object (for fluent API support) + * @param ChildProduct $l ChildProduct + * @return \Thelia\Model\TaxRule The current object (for fluent API support) */ - public function addProduct(Product $l) + public function addProduct(ChildProduct $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); } @@ -1462,7 +1578,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } /** - * @param Product $product The product object to add. + * @param Product $product The product object to add. */ protected function doAddProduct($product) { @@ -1471,8 +1587,8 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } /** - * @param Product $product The product object to remove. - * @return TaxRule The current object (for fluent API support) + * @param Product $product The product object to remove. + * @return ChildTaxRule The current object (for fluent API support) */ public function removeProduct($product) { @@ -1490,109 +1606,106 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } /** - * Clears out the collTaxRuleCountrys collection + * Clears out the collTaxRuleCountries collection * * This 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 + * @see addTaxRuleCountries() */ - public function resetPartialTaxRuleCountrys($v = true) + public function clearTaxRuleCountries() { - $this->collTaxRuleCountrysPartial = $v; + $this->collTaxRuleCountries = null; // important to set this to NULL since that means it is uninitialized } /** - * Initializes the collTaxRuleCountrys collection. + * Reset is the collTaxRuleCountries collection loaded partially. + */ + public function resetPartialTaxRuleCountries($v = true) + { + $this->collTaxRuleCountriesPartial = $v; + } + + /** + * Initializes the collTaxRuleCountries collection. * - * By default this just sets the collTaxRuleCountrys collection to an empty array (like clearcollTaxRuleCountrys()); + * By default this just sets the collTaxRuleCountries collection to an empty array (like clearcollTaxRuleCountries()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @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) + public function initTaxRuleCountries($overrideExisting = true) { - if (null !== $this->collTaxRuleCountrys && !$overrideExisting) { + if (null !== $this->collTaxRuleCountries && !$overrideExisting) { return; } - $this->collTaxRuleCountrys = new PropelObjectCollection(); - $this->collTaxRuleCountrys->setModel('TaxRuleCountry'); + $this->collTaxRuleCountries = new ObjectCollection(); + $this->collTaxRuleCountries->setModel('\Thelia\Model\TaxRuleCountry'); } /** - * Gets an array of TaxRuleCountry objects which contain a foreign key that references this object. + * Gets an array of ChildTaxRuleCountry objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildTaxRule is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects * @throws PropelException */ - public function getTaxRuleCountrys($criteria = null, PropelPDO $con = null) + public function getTaxRuleCountries($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { + $partial = $this->collTaxRuleCountriesPartial && !$this->isNew(); + if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTaxRuleCountries) { // return empty collection - $this->initTaxRuleCountrys(); + $this->initTaxRuleCountries(); } else { - $collTaxRuleCountrys = TaxRuleCountryQuery::create(null, $criteria) + $collTaxRuleCountries = ChildTaxRuleCountryQuery::create(null, $criteria) ->filterByTaxRule($this) ->find($con); + if (null !== $criteria) { - if (false !== $this->collTaxRuleCountrysPartial && count($collTaxRuleCountrys)) { - $this->initTaxRuleCountrys(false); + if (false !== $this->collTaxRuleCountriesPartial && count($collTaxRuleCountries)) { + $this->initTaxRuleCountries(false); - foreach($collTaxRuleCountrys as $obj) { - if (false == $this->collTaxRuleCountrys->contains($obj)) { - $this->collTaxRuleCountrys->append($obj); + foreach ($collTaxRuleCountries as $obj) { + if (false == $this->collTaxRuleCountries->contains($obj)) { + $this->collTaxRuleCountries->append($obj); + } } - } - $this->collTaxRuleCountrysPartial = true; + $this->collTaxRuleCountriesPartial = true; } - $collTaxRuleCountrys->getInternalIterator()->rewind(); - return $collTaxRuleCountrys; + $collTaxRuleCountries->getInternalIterator()->rewind(); + + return $collTaxRuleCountries; } - if($partial && $this->collTaxRuleCountrys) { - foreach($this->collTaxRuleCountrys as $obj) { - if($obj->isNew()) { - $collTaxRuleCountrys[] = $obj; + if ($partial && $this->collTaxRuleCountries) { + foreach ($this->collTaxRuleCountries as $obj) { + if ($obj->isNew()) { + $collTaxRuleCountries[] = $obj; } } } - $this->collTaxRuleCountrys = $collTaxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; + $this->collTaxRuleCountries = $collTaxRuleCountries; + $this->collTaxRuleCountriesPartial = false; } } - return $this->collTaxRuleCountrys; + return $this->collTaxRuleCountries; } /** @@ -1601,27 +1714,28 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * It will 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) + * @param Collection $taxRuleCountries A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTaxRule The current object (for fluent API support) */ - public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null) + public function setTaxRuleCountries(Collection $taxRuleCountries, ConnectionInterface $con = null) { - $taxRuleCountrysToDelete = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); + $taxRuleCountriesToDelete = $this->getTaxRuleCountries(new Criteria(), $con)->diff($taxRuleCountries); - $this->taxRuleCountrysScheduledForDeletion = unserialize(serialize($taxRuleCountrysToDelete)); - foreach ($taxRuleCountrysToDelete as $taxRuleCountryRemoved) { + $this->taxRuleCountriesScheduledForDeletion = $taxRuleCountriesToDelete; + + foreach ($taxRuleCountriesToDelete as $taxRuleCountryRemoved) { $taxRuleCountryRemoved->setTaxRule(null); } - $this->collTaxRuleCountrys = null; - foreach ($taxRuleCountrys as $taxRuleCountry) { + $this->collTaxRuleCountries = null; + foreach ($taxRuleCountries as $taxRuleCountry) { $this->addTaxRuleCountry($taxRuleCountry); } - $this->collTaxRuleCountrys = $taxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; + $this->collTaxRuleCountries = $taxRuleCountries; + $this->collTaxRuleCountriesPartial = false; return $this; } @@ -1629,24 +1743,25 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Returns the number of related TaxRuleCountry objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related TaxRuleCountry objects. * @throws PropelException */ - public function countTaxRuleCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countTaxRuleCountries(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { + $partial = $this->collTaxRuleCountriesPartial && !$this->isNew(); + if (null === $this->collTaxRuleCountries || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collTaxRuleCountries) { return 0; } - if($partial && !$criteria) { - return count($this->getTaxRuleCountrys()); + if ($partial && !$criteria) { + return count($this->getTaxRuleCountries()); } - $query = TaxRuleCountryQuery::create(null, $criteria); + + $query = ChildTaxRuleCountryQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1656,23 +1771,24 @@ abstract class BaseTaxRule extends BaseObject implements Persistent ->count($con); } - return count($this->collTaxRuleCountrys); + return count($this->collTaxRuleCountries); } /** - * Method called to associate a TaxRuleCountry object to this object - * through the TaxRuleCountry foreign key attribute. + * Method called to associate a ChildTaxRuleCountry object to this object + * through the ChildTaxRuleCountry foreign key attribute. * - * @param TaxRuleCountry $l TaxRuleCountry - * @return TaxRule The current object (for fluent API support) + * @param ChildTaxRuleCountry $l ChildTaxRuleCountry + * @return \Thelia\Model\TaxRule The current object (for fluent API support) */ - public function addTaxRuleCountry(TaxRuleCountry $l) + public function addTaxRuleCountry(ChildTaxRuleCountry $l) { - if ($this->collTaxRuleCountrys === null) { - $this->initTaxRuleCountrys(); - $this->collTaxRuleCountrysPartial = true; + if ($this->collTaxRuleCountries === null) { + $this->initTaxRuleCountries(); + $this->collTaxRuleCountriesPartial = true; } - if (!in_array($l, $this->collTaxRuleCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + + if (!in_array($l, $this->collTaxRuleCountries->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddTaxRuleCountry($l); } @@ -1680,27 +1796,27 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add. + * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add. */ protected function doAddTaxRuleCountry($taxRuleCountry) { - $this->collTaxRuleCountrys[]= $taxRuleCountry; + $this->collTaxRuleCountries[]= $taxRuleCountry; $taxRuleCountry->setTaxRule($this); } /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. - * @return TaxRule The current object (for fluent API support) + * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. + * @return ChildTaxRule 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(); + if ($this->getTaxRuleCountries()->contains($taxRuleCountry)) { + $this->collTaxRuleCountries->remove($this->collTaxRuleCountries->search($taxRuleCountry)); + if (null === $this->taxRuleCountriesScheduledForDeletion) { + $this->taxRuleCountriesScheduledForDeletion = clone $this->collTaxRuleCountries; + $this->taxRuleCountriesScheduledForDeletion->clear(); } - $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry; + $this->taxRuleCountriesScheduledForDeletion[]= $taxRuleCountry; $taxRuleCountry->setTaxRule(null); } @@ -1713,23 +1829,23 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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. + * been saved, it will retrieve related TaxRuleCountries from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects */ - public function getTaxRuleCountrysJoinTax($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getTaxRuleCountriesJoinTax($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('Tax', $join_behavior); + $query = ChildTaxRuleCountryQuery::create(null, $criteria); + $query->joinWith('Tax', $joinBehavior); - return $this->getTaxRuleCountrys($query, $con); + return $this->getTaxRuleCountries($query, $con); } @@ -1738,23 +1854,23 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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. + * been saved, it will retrieve related TaxRuleCountries from storage. * * This 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildTaxRuleCountry[] List of ChildTaxRuleCountry objects */ - public function getTaxRuleCountrysJoinCountry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) + public function getTaxRuleCountriesJoinCountry($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('Country', $join_behavior); + $query = ChildTaxRuleCountryQuery::create(null, $criteria); + $query->joinWith('Country', $joinBehavior); - return $this->getTaxRuleCountrys($query, $con); + return $this->getTaxRuleCountries($query, $con); } /** @@ -1763,21 +1879,16 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * This 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) + * @return void * @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; + $this->collTaxRuleI18ns = null; // important to set this to NULL since that means it is uninitialized } /** - * reset is the collTaxRuleI18ns collection loaded partially - * - * @return void + * Reset is the collTaxRuleI18ns collection loaded partially. */ public function resetPartialTaxRuleI18ns($v = true) { @@ -1791,7 +1902,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * - * @param boolean $overrideExisting If set to true, the method call initializes + * @param boolean $overrideExisting If set to true, the method call initializes * the collection even if it is not empty * * @return void @@ -1801,25 +1912,25 @@ abstract class BaseTaxRule extends BaseObject implements Persistent if (null !== $this->collTaxRuleI18ns && !$overrideExisting) { return; } - $this->collTaxRuleI18ns = new PropelObjectCollection(); - $this->collTaxRuleI18ns->setModel('TaxRuleI18n'); + $this->collTaxRuleI18ns = new ObjectCollection(); + $this->collTaxRuleI18ns->setModel('\Thelia\Model\TaxRuleI18n'); } /** - * Gets an array of TaxRuleI18n objects which contain a foreign key that references this object. + * Gets an array of ChildTaxRuleI18n objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched 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 + * If this ChildTaxRule is new, it will return * an empty collection or the current collection; the criteria 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 + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildTaxRuleI18n[] List of ChildTaxRuleI18n objects * @throws PropelException */ - public function getTaxRuleI18ns($criteria = null, PropelPDO $con = null) + public function getTaxRuleI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collTaxRuleI18nsPartial && !$this->isNew(); if (null === $this->collTaxRuleI18ns || null !== $criteria || $partial) { @@ -1827,29 +1938,31 @@ abstract class BaseTaxRule extends BaseObject implements Persistent // return empty collection $this->initTaxRuleI18ns(); } else { - $collTaxRuleI18ns = TaxRuleI18nQuery::create(null, $criteria) + $collTaxRuleI18ns = ChildTaxRuleI18nQuery::create(null, $criteria) ->filterByTaxRule($this) ->find($con); + if (null !== $criteria) { if (false !== $this->collTaxRuleI18nsPartial && count($collTaxRuleI18ns)) { - $this->initTaxRuleI18ns(false); + $this->initTaxRuleI18ns(false); - foreach($collTaxRuleI18ns as $obj) { - if (false == $this->collTaxRuleI18ns->contains($obj)) { - $this->collTaxRuleI18ns->append($obj); + foreach ($collTaxRuleI18ns as $obj) { + if (false == $this->collTaxRuleI18ns->contains($obj)) { + $this->collTaxRuleI18ns->append($obj); + } } - } - $this->collTaxRuleI18nsPartial = true; + $this->collTaxRuleI18nsPartial = true; } $collTaxRuleI18ns->getInternalIterator()->rewind(); + return $collTaxRuleI18ns; } - if($partial && $this->collTaxRuleI18ns) { - foreach($this->collTaxRuleI18ns as $obj) { - if($obj->isNew()) { + if ($partial && $this->collTaxRuleI18ns) { + foreach ($this->collTaxRuleI18ns as $obj) { + if ($obj->isNew()) { $collTaxRuleI18ns[] = $obj; } } @@ -1869,15 +1982,19 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * It will 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) + * @param Collection $taxRuleI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildTaxRule The current object (for fluent API support) */ - public function setTaxRuleI18ns(PropelCollection $taxRuleI18ns, PropelPDO $con = null) + public function setTaxRuleI18ns(Collection $taxRuleI18ns, ConnectionInterface $con = null) { $taxRuleI18nsToDelete = $this->getTaxRuleI18ns(new Criteria(), $con)->diff($taxRuleI18ns); - $this->taxRuleI18nsScheduledForDeletion = unserialize(serialize($taxRuleI18nsToDelete)); + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->taxRuleI18nsScheduledForDeletion = clone $taxRuleI18nsToDelete; foreach ($taxRuleI18nsToDelete as $taxRuleI18nRemoved) { $taxRuleI18nRemoved->setTaxRule(null); @@ -1897,13 +2014,13 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Returns the number of related TaxRuleI18n objects. * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con * @return int Count of related TaxRuleI18n objects. * @throws PropelException */ - public function countTaxRuleI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) + public function countTaxRuleI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collTaxRuleI18nsPartial && !$this->isNew(); if (null === $this->collTaxRuleI18ns || null !== $criteria || $partial) { @@ -1911,10 +2028,11 @@ abstract class BaseTaxRule extends BaseObject implements Persistent return 0; } - if($partial && !$criteria) { + if ($partial && !$criteria) { return count($this->getTaxRuleI18ns()); } - $query = TaxRuleI18nQuery::create(null, $criteria); + + $query = ChildTaxRuleI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1928,13 +2046,13 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } /** - * Method called to associate a TaxRuleI18n object to this object - * through the TaxRuleI18n foreign key attribute. + * Method called to associate a ChildTaxRuleI18n object to this object + * through the ChildTaxRuleI18n foreign key attribute. * - * @param TaxRuleI18n $l TaxRuleI18n - * @return TaxRule The current object (for fluent API support) + * @param ChildTaxRuleI18n $l ChildTaxRuleI18n + * @return \Thelia\Model\TaxRule The current object (for fluent API support) */ - public function addTaxRuleI18n(TaxRuleI18n $l) + public function addTaxRuleI18n(ChildTaxRuleI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); @@ -1944,6 +2062,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $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); } @@ -1952,7 +2071,7 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } /** - * @param TaxRuleI18n $taxRuleI18n The taxRuleI18n object to add. + * @param TaxRuleI18n $taxRuleI18n The taxRuleI18n object to add. */ protected function doAddTaxRuleI18n($taxRuleI18n) { @@ -1961,8 +2080,8 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } /** - * @param TaxRuleI18n $taxRuleI18n The taxRuleI18n object to remove. - * @return TaxRule The current object (for fluent API support) + * @param TaxRuleI18n $taxRuleI18n The taxRuleI18n object to remove. + * @return ChildTaxRule The current object (for fluent API support) */ public function removeTaxRuleI18n($taxRuleI18n) { @@ -1991,8 +2110,6 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); @@ -2004,21 +2121,20 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * * 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. + * when using Propel in certain daemon or large-volume/high-memory operations. * - * @param boolean $deep Whether to also clear the references on all referrer objects. + * @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 ($deep) { if ($this->collProducts) { foreach ($this->collProducts as $o) { $o->clearAllReferences($deep); } } - if ($this->collTaxRuleCountrys) { - foreach ($this->collTaxRuleCountrys as $o) { + if ($this->collTaxRuleCountries) { + foreach ($this->collTaxRuleCountries as $o) { $o->clearAllReferences($deep); } } @@ -2027,46 +2143,34 @@ abstract class BaseTaxRule extends BaseObject implements Persistent $o->clearAllReferences($deep); } } - - $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) // i18n behavior - $this->currentLocale = 'en_US'; + $this->currentLocale = 'en_EN'; $this->currentTranslations = null; - if ($this->collProducts instanceof PropelCollection) { + if ($this->collProducts instanceof Collection) { $this->collProducts->clearIterator(); } $this->collProducts = null; - if ($this->collTaxRuleCountrys instanceof PropelCollection) { - $this->collTaxRuleCountrys->clearIterator(); + if ($this->collTaxRuleCountries instanceof Collection) { + $this->collTaxRuleCountries->clearIterator(); } - $this->collTaxRuleCountrys = null; - if ($this->collTaxRuleI18ns instanceof PropelCollection) { + $this->collTaxRuleCountries = null; + if ($this->collTaxRuleI18ns instanceof Collection) { $this->collTaxRuleI18ns->clearIterator(); } $this->collTaxRuleI18ns = null; } /** - * return the string representation of this object + * 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; + return (string) $this->exportTo(TaxRuleTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -2074,11 +2178,11 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * 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) + * @return ChildTaxRule The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = TaxRulePeer::UPDATED_AT; + $this->modifiedColumns[] = TaxRuleTableMap::UPDATED_AT; return $this; } @@ -2090,9 +2194,9 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * - * @return TaxRule The current object (for fluent API support) + * @return ChildTaxRule The current object (for fluent API support) */ - public function setLocale($locale = 'en_US') + public function setLocale($locale = 'en_EN') { $this->currentLocale = $locale; @@ -2113,10 +2217,10 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return TaxRuleI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) + * @return ChildTaxRuleI18n */ + public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collTaxRuleI18ns) { @@ -2129,10 +2233,10 @@ abstract class BaseTaxRule extends BaseObject implements Persistent } } if ($this->isNew()) { - $translation = new TaxRuleI18n(); + $translation = new ChildTaxRuleI18n(); $translation->setLocale($locale); } else { - $translation = TaxRuleI18nQuery::create() + $translation = ChildTaxRuleI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; @@ -2147,14 +2251,14 @@ abstract class BaseTaxRule extends BaseObject implements Persistent * 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 + * @param ConnectionInterface $con an optional connection object * - * @return TaxRule The current object (for fluent API support) + * @return ChildTaxRule The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) + public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) { if (!$this->isNew()) { - TaxRuleI18nQuery::create() + ChildTaxRuleI18nQuery::create() ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) ->delete($con); } @@ -2174,12 +2278,130 @@ abstract class BaseTaxRule extends BaseObject implements Persistent /** * Returns the current translation * - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return TaxRuleI18n */ - public function getCurrentTranslation(PropelPDO $con = null) + * @return ChildTaxRuleI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) { return $this->getTranslation($this->getLocale(), $con); } + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + } diff --git a/core/lib/Thelia/Model/Base/TaxRuleCountry.php b/core/lib/Thelia/Model/Base/TaxRuleCountry.php new file mode 100644 index 000000000..b5ae7941b --- /dev/null +++ b/core/lib/Thelia/Model/Base/TaxRuleCountry.php @@ -0,0 +1,1677 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another TaxRuleCountry instance. If + * obj is an instance of TaxRuleCountry, delegates to + * equals(TaxRuleCountry). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return TaxRuleCountry The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return TaxRuleCountry The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 [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 = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at !== null ? $this->created_at->format($format) : null; + } + } + + /** + * 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 = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at !== null ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = TaxRuleCountryTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [tax_rule_id] column. + * + * @param int $v new value + * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support) + */ + public function setTaxRuleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->tax_rule_id !== $v) { + $this->tax_rule_id = $v; + $this->modifiedColumns[] = TaxRuleCountryTableMap::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 \Thelia\Model\TaxRuleCountry The current object (for fluent API support) + */ + public function setCountryId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->country_id !== $v) { + $this->country_id = $v; + $this->modifiedColumns[] = TaxRuleCountryTableMap::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 \Thelia\Model\TaxRuleCountry The current object (for fluent API support) + */ + public function setTaxId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->tax_id !== $v) { + $this->tax_id = $v; + $this->modifiedColumns[] = TaxRuleCountryTableMap::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 \Thelia\Model\TaxRuleCountry The current object (for fluent API support) + */ + public function setNone($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->none !== $v) { + $this->none = $v; + $this->modifiedColumns[] = TaxRuleCountryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = TaxRuleCountryTableMap::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 \Thelia\Model\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) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = TaxRuleCountryTableMap::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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleCountryTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleCountryTableMap::translateFieldName('TaxRuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_rule_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleCountryTableMap::translateFieldName('CountryId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->country_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxRuleCountryTableMap::translateFieldName('TaxId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->tax_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : TaxRuleCountryTableMap::translateFieldName('None', TableMap::TYPE_PHPNAME, $indexType)]; + $this->none = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : TaxRuleCountryTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : TaxRuleCountryTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = TaxRuleCountryTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\TaxRuleCountry object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(TaxRuleCountryTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildTaxRuleCountryQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // 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 ConnectionInterface $con + * @return void + * @throws PropelException + * @see TaxRuleCountry::setDeleted() + * @see TaxRuleCountry::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildTaxRuleCountryQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(TaxRuleCountryTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(TaxRuleCountryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(TaxRuleCountryTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + TaxRuleCountryTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(TaxRuleCountryTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(TaxRuleCountryTableMap::TAX_RULE_ID)) { + $modifiedColumns[':p' . $index++] = 'TAX_RULE_ID'; + } + if ($this->isColumnModified(TaxRuleCountryTableMap::COUNTRY_ID)) { + $modifiedColumns[':p' . $index++] = 'COUNTRY_ID'; + } + if ($this->isColumnModified(TaxRuleCountryTableMap::TAX_ID)) { + $modifiedColumns[':p' . $index++] = 'TAX_ID'; + } + if ($this->isColumnModified(TaxRuleCountryTableMap::NONE)) { + $modifiedColumns[':p' . $index++] = 'NONE'; + } + if ($this->isColumnModified(TaxRuleCountryTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(TaxRuleCountryTableMap::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 ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, 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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = TaxRuleCountryTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['TaxRuleCountry'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['TaxRuleCountry'][$this->getPrimaryKey()] = true; + $keys = TaxRuleCountryTableMap::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(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = TaxRuleCountryTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = TaxRuleCountryTableMap::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(TaxRuleCountryTableMap::DATABASE_NAME); + + if ($this->isColumnModified(TaxRuleCountryTableMap::ID)) $criteria->add(TaxRuleCountryTableMap::ID, $this->id); + if ($this->isColumnModified(TaxRuleCountryTableMap::TAX_RULE_ID)) $criteria->add(TaxRuleCountryTableMap::TAX_RULE_ID, $this->tax_rule_id); + if ($this->isColumnModified(TaxRuleCountryTableMap::COUNTRY_ID)) $criteria->add(TaxRuleCountryTableMap::COUNTRY_ID, $this->country_id); + if ($this->isColumnModified(TaxRuleCountryTableMap::TAX_ID)) $criteria->add(TaxRuleCountryTableMap::TAX_ID, $this->tax_id); + if ($this->isColumnModified(TaxRuleCountryTableMap::NONE)) $criteria->add(TaxRuleCountryTableMap::NONE, $this->none); + if ($this->isColumnModified(TaxRuleCountryTableMap::CREATED_AT)) $criteria->add(TaxRuleCountryTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(TaxRuleCountryTableMap::UPDATED_AT)) $criteria->add(TaxRuleCountryTableMap::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(TaxRuleCountryTableMap::DATABASE_NAME); + $criteria->add(TaxRuleCountryTableMap::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 \Thelia\Model\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->setId($this->getId()); + $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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildTax object. + * + * @param ChildTax $v + * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support) + * @throws PropelException + */ + public function setTax(ChildTax $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 ChildTax object, it will not be re-added. + if ($v !== null) { + $v->addTaxRuleCountry($this); + } + + + return $this; + } + + + /** + * Get the associated ChildTax object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildTax The associated ChildTax object. + * @throws PropelException + */ + public function getTax(ConnectionInterface $con = null) + { + if ($this->aTax === null && ($this->tax_id !== null)) { + $this->aTax = ChildTaxQuery::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->addTaxRuleCountries($this); + */ + } + + return $this->aTax; + } + + /** + * Declares an association between this object and a ChildTaxRule object. + * + * @param ChildTaxRule $v + * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support) + * @throws PropelException + */ + public function setTaxRule(ChildTaxRule $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 ChildTaxRule object, it will not be re-added. + if ($v !== null) { + $v->addTaxRuleCountry($this); + } + + + return $this; + } + + + /** + * Get the associated ChildTaxRule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildTaxRule The associated ChildTaxRule object. + * @throws PropelException + */ + public function getTaxRule(ConnectionInterface $con = null) + { + if ($this->aTaxRule === null && ($this->tax_rule_id !== null)) { + $this->aTaxRule = ChildTaxRuleQuery::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->addTaxRuleCountries($this); + */ + } + + return $this->aTaxRule; + } + + /** + * Declares an association between this object and a ChildCountry object. + * + * @param ChildCountry $v + * @return \Thelia\Model\TaxRuleCountry The current object (for fluent API support) + * @throws PropelException + */ + public function setCountry(ChildCountry $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 ChildCountry object, it will not be re-added. + if ($v !== null) { + $v->addTaxRuleCountry($this); + } + + + return $this; + } + + + /** + * Get the associated ChildCountry object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildCountry The associated ChildCountry object. + * @throws PropelException + */ + public function getCountry(ConnectionInterface $con = null) + { + if ($this->aCountry === null && ($this->country_id !== null)) { + $this->aCountry = ChildCountryQuery::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->addTaxRuleCountries($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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aTax = null; + $this->aTaxRule = null; + $this->aCountry = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(TaxRuleCountryTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildTaxRuleCountry The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = TaxRuleCountryTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php b/core/lib/Thelia/Model/Base/TaxRuleCountryQuery.php old mode 100755 new mode 100644 similarity index 53% rename from core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php rename to core/lib/Thelia/Model/Base/TaxRuleCountryQuery.php index c78697899..b4d4cd1c2 --- a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php +++ b/core/lib/Thelia/Model/Base/TaxRuleCountryQuery.php @@ -1,109 +1,107 @@ setModelAlias($modelAlias); } @@ -124,21 +122,21 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return TaxRuleCountry|TaxRuleCountry[]|mixed the result, formatted by the current formatter + * @return ChildTaxRuleCountry|array|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 + if ((null !== ($obj = TaxRuleCountryTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(TaxRuleCountryTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -150,46 +148,31 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return TaxRuleCountry A model object, or null if the key is not found - * @throws PropelException + * @return ChildTaxRuleCountry A model object, or null if the key is not found */ 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'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new TaxRuleCountry(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildTaxRuleCountry(); $obj->hydrate($row); - TaxRuleCountryPeer::addInstanceToPool($obj, (string) $key); + TaxRuleCountryTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -200,19 +183,19 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return TaxRuleCountry|TaxRuleCountry[]|mixed the result, formatted by the current formatter + * @return ChildTaxRuleCountry|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -221,22 +204,22 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|TaxRuleCountry[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -244,12 +227,12 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return TaxRuleCountryQuery The current query, for fluid interface + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(TaxRuleCountryPeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(TaxRuleCountryTableMap::ID, $key, Criteria::EQUAL); } /** @@ -257,12 +240,12 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return TaxRuleCountryQuery The current query, for fluid interface + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(TaxRuleCountryPeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(TaxRuleCountryTableMap::ID, $keys, Criteria::IN); } /** @@ -272,8 +255,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -282,18 +264,18 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * 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 + * @return ChildTaxRuleCountryQuery 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); + $this->addUsingAlias(TaxRuleCountryTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxRuleCountryTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -304,7 +286,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRuleCountryPeer::ID, $id, $comparison); + return $this->addUsingAlias(TaxRuleCountryTableMap::ID, $id, $comparison); } /** @@ -314,8 +296,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $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 + * $query->filterByTaxRuleId(array('min' => 12)); // WHERE tax_rule_id > 12 * * * @see filterByTaxRule() @@ -326,18 +307,18 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * 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 + * @return ChildTaxRuleCountryQuery 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); + $this->addUsingAlias(TaxRuleCountryTableMap::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); + $this->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -348,7 +329,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRuleId, $comparison); + return $this->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $taxRuleId, $comparison); } /** @@ -358,8 +339,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $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 + * $query->filterByCountryId(array('min' => 12)); // WHERE country_id > 12 * * * @see filterByCountry() @@ -370,18 +350,18 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * 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 + * @return ChildTaxRuleCountryQuery 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); + $this->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($countryId['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -392,7 +372,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $countryId, $comparison); + return $this->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $countryId, $comparison); } /** @@ -402,8 +382,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $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 + * $query->filterByTaxId(array('min' => 12)); // WHERE tax_id > 12 * * * @see filterByTax() @@ -414,18 +393,18 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * 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 + * @return ChildTaxRuleCountryQuery 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); + $this->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $taxId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($taxId['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $taxId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $taxId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -436,7 +415,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $taxId, $comparison); + return $this->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $taxId, $comparison); } /** @@ -446,8 +425,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * $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 + * $query->filterByNone(array('min' => 12)); // WHERE none > 12 * * * @param mixed $none The value to use as filter. @@ -456,18 +434,18 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * 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 + * @return ChildTaxRuleCountryQuery 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); + $this->addUsingAlias(TaxRuleCountryTableMap::NONE, $none['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($none['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::NONE, $none['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxRuleCountryTableMap::NONE, $none['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -478,7 +456,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRuleCountryPeer::NONE, $none, $comparison); + return $this->addUsingAlias(TaxRuleCountryTableMap::NONE, $none, $comparison); } /** @@ -499,18 +477,18 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * 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 + * @return ChildTaxRuleCountryQuery 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); + $this->addUsingAlias(TaxRuleCountryTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxRuleCountryTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -521,7 +499,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(TaxRuleCountryTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -542,18 +520,18 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * 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 + * @return ChildTaxRuleCountryQuery 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); + $this->addUsingAlias(TaxRuleCountryTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxRuleCountryTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -564,32 +542,31 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(TaxRuleCountryTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Tax object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Tax|ObjectCollection $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. + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function filterByTax($tax, $comparison = null) { - if ($tax instanceof Tax) { + if ($tax instanceof \Thelia\Model\Tax) { return $this - ->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $tax->getId(), $comparison); - } elseif ($tax instanceof PropelObjectCollection) { + ->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $tax->getId(), $comparison); + } elseif ($tax instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(TaxRuleCountryTableMap::TAX_ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection'); + throw new PropelException('filterByTax() only accepts arguments of type \Thelia\Model\Tax or Collection'); } } @@ -599,7 +576,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * @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 + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function joinTax($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -628,7 +605,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria /** * Use the Tax relation Tax object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -644,28 +621,27 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } /** - * Filter the query by a related TaxRule object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\TaxRule|ObjectCollection $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. + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function filterByTaxRule($taxRule, $comparison = null) { - if ($taxRule instanceof TaxRule) { + if ($taxRule instanceof \Thelia\Model\TaxRule) { return $this - ->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRule->getId(), $comparison); - } elseif ($taxRule instanceof PropelObjectCollection) { + ->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $taxRule->getId(), $comparison); + } elseif ($taxRule instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(TaxRuleCountryTableMap::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection'); + throw new PropelException('filterByTaxRule() only accepts arguments of type \Thelia\Model\TaxRule or Collection'); } } @@ -675,7 +651,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * @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 + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -704,7 +680,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria /** * Use the TaxRule relation TaxRule object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -720,28 +696,27 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria } /** - * Filter the query by a related Country object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Country|ObjectCollection $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. + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function filterByCountry($country, $comparison = null) { - if ($country instanceof Country) { + if ($country instanceof \Thelia\Model\Country) { return $this - ->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $country->getId(), $comparison); - } elseif ($country instanceof PropelObjectCollection) { + ->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $country->getId(), $comparison); + } elseif ($country instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(TaxRuleCountryTableMap::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { - throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection'); + throw new PropelException('filterByCountry() only accepts arguments of type \Thelia\Model\Country or Collection'); } } @@ -751,7 +726,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * @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 + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -780,7 +755,7 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria /** * Use the Country relation Country object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -798,19 +773,94 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria /** * Exclude object from result * - * @param TaxRuleCountry $taxRuleCountry Object to remove from the list of results + * @param ChildTaxRuleCountry $taxRuleCountry Object to remove from the list of results * - * @return TaxRuleCountryQuery The current query, for fluid interface + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function prune($taxRuleCountry = null) { if ($taxRuleCountry) { - $this->addUsingAlias(TaxRuleCountryPeer::ID, $taxRuleCountry->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(TaxRuleCountryTableMap::ID, $taxRuleCountry->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the tax_rule_country table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + TaxRuleCountryTableMap::clearInstancePool(); + TaxRuleCountryTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildTaxRuleCountry or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildTaxRuleCountry object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(TaxRuleCountryTableMap::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(); + + + TaxRuleCountryTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + TaxRuleCountryTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -818,31 +868,11 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return TaxRuleCountryQuery The current query, for fluid interface + * @return ChildTaxRuleCountryQuery 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); + return $this->addUsingAlias(TaxRuleCountryTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -850,30 +880,51 @@ abstract class BaseTaxRuleCountryQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return TaxRuleCountryQuery The current query, for fluid interface + * @return ChildTaxRuleCountryQuery 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); + return $this->addUsingAlias(TaxRuleCountryTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildTaxRuleCountryQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(TaxRuleCountryTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildTaxRuleCountryQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(TaxRuleCountryTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return TaxRuleCountryQuery The current query, for fluid interface + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(TaxRuleCountryPeer::CREATED_AT); + return $this->addDescendingOrderByColumn(TaxRuleCountryTableMap::CREATED_AT); } /** * Order by create date asc * - * @return TaxRuleCountryQuery The current query, for fluid interface + * @return ChildTaxRuleCountryQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(TaxRuleCountryPeer::CREATED_AT); + return $this->addAscendingOrderByColumn(TaxRuleCountryTableMap::CREATED_AT); } -} + +} // TaxRuleCountryQuery diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18n.php b/core/lib/Thelia/Model/Base/TaxRuleI18n.php new file mode 100644 index 000000000..86215b335 --- /dev/null +++ b/core/lib/Thelia/Model/Base/TaxRuleI18n.php @@ -0,0 +1,1207 @@ +locale = 'en_EN'; + } + + /** + * Initializes internal state of Thelia\Model\Base\TaxRuleI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another TaxRuleI18n instance. If + * obj is an instance of TaxRuleI18n, delegates to + * equals(TaxRuleI18n). Otherwise, returns false. + * + * @param obj The object to compare to. + * @return Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @param string $name The virtual column name + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @return boolean + */ + public function hasVirtualColumn($name) + { + return isset($this->virtualColumns[$name]); + } + + /** + * Get the value of a virtual column in this object + * + * @return mixed + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return TaxRuleI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return TaxRuleI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * 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 \Thelia\Model\TaxRuleI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = TaxRuleI18nTableMap::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 \Thelia\Model\TaxRuleI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = TaxRuleI18nTableMap::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_EN') { + 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 DataFetcher->fetch(). + * @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. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 2; // 2 = TaxRuleI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\TaxRuleI18n object", 0, $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 ConnectionInterface $con (optional) The ConnectionInterface 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, ConnectionInterface $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::getServiceContainer()->getReadConnection(TaxRuleI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildTaxRuleI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aTaxRule = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see TaxRuleI18n::setDeleted() + * @see TaxRuleI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildTaxRuleI18nQuery::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 ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME); + } + + $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); + TaxRuleI18nTableMap::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 ConnectionInterface $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(ConnectionInterface $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 corresponding 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 ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(TaxRuleI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(TaxRuleI18nTableMap::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), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = TaxRuleI18nTableMap::translateFieldName($name, $type, TableMap::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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::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 = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['TaxRuleI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['TaxRuleI18n'][serialize($this->getPrimaryKey())] = true; + $keys = TaxRuleI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + ); + $virtualColumns = $this->virtualColumns; + foreach($virtualColumns as $key => $virtualColumn) + { + $result[$key] = $virtualColumn; + } + + 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 + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = TaxRuleI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::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 = TableMap::TYPE_PHPNAME) + { + $keys = TaxRuleI18nTableMap::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(TaxRuleI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(TaxRuleI18nTableMap::ID)) $criteria->add(TaxRuleI18nTableMap::ID, $this->id); + if ($this->isColumnModified(TaxRuleI18nTableMap::LOCALE)) $criteria->add(TaxRuleI18nTableMap::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(TaxRuleI18nTableMap::DATABASE_NAME); + $criteria->add(TaxRuleI18nTableMap::ID, $this->id); + $criteria->add(TaxRuleI18nTableMap::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 \Thelia\Model\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 ($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 \Thelia\Model\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; + } + + /** + * Declares an association between this object and a ChildTaxRule object. + * + * @param ChildTaxRule $v + * @return \Thelia\Model\TaxRuleI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setTaxRule(ChildTaxRule $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 ChildTaxRule object, it will not be re-added. + if ($v !== null) { + $v->addTaxRuleI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildTaxRule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildTaxRule The associated ChildTaxRule object. + * @throws PropelException + */ + public function getTaxRule(ConnectionInterface $con = null) + { + if ($this->aTaxRule === null && ($this->id !== null)) { + $this->aTaxRule = ChildTaxRuleQuery::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->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-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aTaxRule = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(TaxRuleI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php b/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php new file mode 100644 index 000000000..02667f4ac --- /dev/null +++ b/core/lib/Thelia/Model/Base/TaxRuleI18nQuery.php @@ -0,0 +1,475 @@ +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[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildTaxRuleI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = TaxRuleI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(TaxRuleI18nTableMap::DATABASE_NAME); + } + $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 ConnectionInterface $con A connection object + * + * @return ChildTaxRuleI18n A model object, or null if the key is not found + */ + 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), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildTaxRuleI18n(); + $obj->hydrate($row); + TaxRuleI18nTableMap::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 ConnectionInterface $con A connection object + * + * @return ChildTaxRuleI18n|array|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; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * 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 ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildTaxRuleI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(TaxRuleI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(TaxRuleI18nTableMap::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 ChildTaxRuleI18nQuery 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(TaxRuleI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(TaxRuleI18nTableMap::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 + * + * + * @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 ChildTaxRuleI18nQuery 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(TaxRuleI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(TaxRuleI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(TaxRuleI18nTableMap::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 ChildTaxRuleI18nQuery 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(TaxRuleI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\TaxRule object + * + * @param \Thelia\Model\TaxRule|ObjectCollection $taxRule The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildTaxRuleI18nQuery The current query, for fluid interface + */ + public function filterByTaxRule($taxRule, $comparison = null) + { + if ($taxRule instanceof \Thelia\Model\TaxRule) { + return $this + ->addUsingAlias(TaxRuleI18nTableMap::ID, $taxRule->getId(), $comparison); + } elseif ($taxRule instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(TaxRuleI18nTableMap::ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByTaxRule() only accepts arguments of type \Thelia\Model\TaxRule or Collection'); + } + } + + /** + * 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 ChildTaxRuleI18nQuery 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 ChildTaxRuleI18n $taxRuleI18n Object to remove from the list of results + * + * @return ChildTaxRuleI18nQuery The current query, for fluid interface + */ + public function prune($taxRuleI18n = null) + { + if ($taxRuleI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(TaxRuleI18nTableMap::ID), $taxRuleI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(TaxRuleI18nTableMap::LOCALE), $taxRuleI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the tax_rule_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + TaxRuleI18nTableMap::clearInstancePool(); + TaxRuleI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildTaxRuleI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildTaxRuleI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(TaxRuleI18nTableMap::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(); + + + TaxRuleI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + TaxRuleI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // TaxRuleI18nQuery diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php b/core/lib/Thelia/Model/Base/TaxRuleQuery.php old mode 100755 new mode 100644 similarity index 57% rename from core/lib/Thelia/Model/om/BaseTaxRuleQuery.php rename to core/lib/Thelia/Model/Base/TaxRuleQuery.php index 5829651c3..36f2edd99 --- a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php +++ b/core/lib/Thelia/Model/Base/TaxRuleQuery.php @@ -1,105 +1,104 @@ setModelAlias($modelAlias); } @@ -120,21 +119,21 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object + * @param ConnectionInterface $con an optional connection object * - * @return TaxRule|TaxRule[]|mixed the result, formatted by the current formatter + * @return ChildTaxRule|array|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 + if ((null !== ($obj = TaxRuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); + $con = Propel::getServiceContainer()->getReadConnection(TaxRuleTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -146,46 +145,31 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } } - /** - * 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 + * @param ConnectionInterface $con A connection object * - * @return TaxRule A model object, or null if the key is not found - * @throws PropelException + * @return ChildTaxRule A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT `id`, `code`, `title`, `description`, `created_at`, `updated_at` FROM `tax_rule` WHERE `id` = :p0'; + $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); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); } $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new TaxRule(); + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildTaxRule(); $obj->hydrate($row); - TaxRulePeer::addInstanceToPool($obj, (string) $key); + TaxRuleTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -196,19 +180,19 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * Find object by primary key. * * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object + * @param ConnectionInterface $con A connection object * - * @return TaxRule|TaxRule[]|mixed the result, formatted by the current formatter + * @return ChildTaxRule|array|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 + $dataFetcher = $criteria ->filterByPrimaryKey($key) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); } /** @@ -217,22 +201,22 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * $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 + * @param ConnectionInterface $con an optional connection object * - * @return PropelObjectCollection|TaxRule[]|mixed the list of results, formatted by the current formatter + * @return ObjectCollection|array|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); + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); } $this->basePreSelect($con); $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria + $dataFetcher = $criteria ->filterByPrimaryKeys($keys) ->doSelect($con); - return $criteria->getFormatter()->init($criteria)->format($stmt); + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); } /** @@ -240,12 +224,12 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return TaxRuleQuery The current query, for fluid interface + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(TaxRulePeer::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(TaxRuleTableMap::ID, $key, Criteria::EQUAL); } /** @@ -253,12 +237,12 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return TaxRuleQuery The current query, for fluid interface + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(TaxRulePeer::ID, $keys, Criteria::IN); + return $this->addUsingAlias(TaxRuleTableMap::ID, $keys, Criteria::IN); } /** @@ -268,8 +252,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * $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 + * $query->filterById(array('min' => 12)); // WHERE id > 12 * * * @param mixed $id The value to use as filter. @@ -278,18 +261,18 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * 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 + * @return ChildTaxRuleQuery 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); + $this->addUsingAlias(TaxRuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(TaxRulePeer::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxRuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -300,7 +283,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRulePeer::ID, $id, $comparison); + return $this->addUsingAlias(TaxRuleTableMap::ID, $id, $comparison); } /** @@ -316,7 +299,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * 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 + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function filterByCode($code = null, $comparison = null) { @@ -329,7 +312,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRulePeer::CODE, $code, $comparison); + return $this->addUsingAlias(TaxRuleTableMap::CODE, $code, $comparison); } /** @@ -345,7 +328,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * 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 + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function filterByTitle($title = null, $comparison = null) { @@ -358,7 +341,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRulePeer::TITLE, $title, $comparison); + return $this->addUsingAlias(TaxRuleTableMap::TITLE, $title, $comparison); } /** @@ -374,7 +357,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * 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 + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function filterByDescription($description = null, $comparison = null) { @@ -387,7 +370,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRulePeer::DESCRIPTION, $description, $comparison); + return $this->addUsingAlias(TaxRuleTableMap::DESCRIPTION, $description, $comparison); } /** @@ -408,18 +391,18 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * 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 + * @return ChildTaxRuleQuery 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); + $this->addUsingAlias(TaxRuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxRuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -430,7 +413,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(TaxRuleTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -451,18 +434,18 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * 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 + * @return ChildTaxRuleQuery 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); + $this->addUsingAlias(TaxRuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(TaxRuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -473,30 +456,29 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } } - return $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(TaxRuleTableMap::UPDATED_AT, $updatedAt, $comparison); } /** - * Filter the query by a related Product object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\Product|ObjectCollection $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. + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function filterByProduct($product, $comparison = null) { - if ($product instanceof Product) { + if ($product instanceof \Thelia\Model\Product) { return $this - ->addUsingAlias(TaxRulePeer::ID, $product->getTaxRuleId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { + ->addUsingAlias(TaxRuleTableMap::ID, $product->getTaxRuleId(), $comparison); + } elseif ($product instanceof ObjectCollection) { return $this ->useProductQuery() ->filterByPrimaryKeys($product->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); + throw new PropelException('filterByProduct() only accepts arguments of type \Thelia\Model\Product or Collection'); } } @@ -506,7 +488,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @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 + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -535,7 +517,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria /** * Use the Product relation Product object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -551,26 +533,25 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } /** - * Filter the query by a related TaxRuleCountry object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\TaxRuleCountry|ObjectCollection $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. + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) { - if ($taxRuleCountry instanceof TaxRuleCountry) { + if ($taxRuleCountry instanceof \Thelia\Model\TaxRuleCountry) { return $this - ->addUsingAlias(TaxRulePeer::ID, $taxRuleCountry->getTaxRuleId(), $comparison); - } elseif ($taxRuleCountry instanceof PropelObjectCollection) { + ->addUsingAlias(TaxRuleTableMap::ID, $taxRuleCountry->getTaxRuleId(), $comparison); + } elseif ($taxRuleCountry instanceof ObjectCollection) { return $this ->useTaxRuleCountryQuery() ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection'); + throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type \Thelia\Model\TaxRuleCountry or Collection'); } } @@ -580,7 +561,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @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 + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { @@ -609,7 +590,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria /** * Use the TaxRuleCountry relation TaxRuleCountry object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -625,26 +606,25 @@ abstract class BaseTaxRuleQuery extends ModelCriteria } /** - * Filter the query by a related TaxRuleI18n object + * Filter the query by a related \Thelia\Model\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 + * @param \Thelia\Model\TaxRuleI18n|ObjectCollection $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. + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function filterByTaxRuleI18n($taxRuleI18n, $comparison = null) { - if ($taxRuleI18n instanceof TaxRuleI18n) { + if ($taxRuleI18n instanceof \Thelia\Model\TaxRuleI18n) { return $this - ->addUsingAlias(TaxRulePeer::ID, $taxRuleI18n->getId(), $comparison); - } elseif ($taxRuleI18n instanceof PropelObjectCollection) { + ->addUsingAlias(TaxRuleTableMap::ID, $taxRuleI18n->getId(), $comparison); + } elseif ($taxRuleI18n instanceof ObjectCollection) { return $this ->useTaxRuleI18nQuery() ->filterByPrimaryKeys($taxRuleI18n->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByTaxRuleI18n() only accepts arguments of type TaxRuleI18n or PropelCollection'); + throw new PropelException('filterByTaxRuleI18n() only accepts arguments of type \Thelia\Model\TaxRuleI18n or Collection'); } } @@ -654,7 +634,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @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 + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function joinTaxRuleI18n($relationAlias = null, $joinType = 'LEFT JOIN') { @@ -683,7 +663,7 @@ abstract class BaseTaxRuleQuery extends ModelCriteria /** * Use the TaxRuleI18n relation TaxRuleI18n object * - * @see useQuery() + * @see useQuery() * * @param string $relationAlias optional alias for the relation, * to be used as main alias in the secondary query @@ -701,19 +681,94 @@ abstract class BaseTaxRuleQuery extends ModelCriteria /** * Exclude object from result * - * @param TaxRule $taxRule Object to remove from the list of results + * @param ChildTaxRule $taxRule Object to remove from the list of results * - * @return TaxRuleQuery The current query, for fluid interface + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function prune($taxRule = null) { if ($taxRule) { - $this->addUsingAlias(TaxRulePeer::ID, $taxRule->getId(), Criteria::NOT_EQUAL); + $this->addUsingAlias(TaxRuleTableMap::ID, $taxRule->getId(), Criteria::NOT_EQUAL); } return $this; } + /** + * Deletes all rows from the tax_rule table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::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 += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + TaxRuleTableMap::clearInstancePool(); + TaxRuleTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildTaxRule or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildTaxRule object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(TaxRuleTableMap::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(); + + + TaxRuleTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + TaxRuleTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + // timestampable behavior /** @@ -721,31 +776,11 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return TaxRuleQuery The current query, for fluid interface + * @return ChildTaxRuleQuery 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); + return $this->addUsingAlias(TaxRuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -753,32 +788,53 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return TaxRuleQuery The current query, for fluid interface + * @return ChildTaxRuleQuery 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); + return $this->addUsingAlias(TaxRuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildTaxRuleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(TaxRuleTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildTaxRuleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(TaxRuleTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return TaxRuleQuery The current query, for fluid interface + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(TaxRulePeer::CREATED_AT); + return $this->addDescendingOrderByColumn(TaxRuleTableMap::CREATED_AT); } /** * Order by create date asc * - * @return TaxRuleQuery The current query, for fluid interface + * @return ChildTaxRuleQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(TaxRulePeer::CREATED_AT); + return $this->addAscendingOrderByColumn(TaxRuleTableMap::CREATED_AT); } + // i18n behavior /** @@ -788,9 +844,9 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @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 + * @return ChildTaxRuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxRuleI18n'; @@ -806,9 +862,9 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @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 + * @return ChildTaxRuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -827,13 +883,13 @@ abstract class BaseTaxRuleQuery extends ModelCriteria * @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 + * @return ChildTaxRuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRuleI18n', 'Thelia\Model\TaxRuleI18nQuery'); + ->useQuery($relationAlias ? $relationAlias : 'TaxRuleI18n', '\Thelia\Model\TaxRuleI18nQuery'); } -} +} // TaxRuleQuery diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php old mode 100755 new mode 100644 index f0b345dbb..25a2ebe48 --- a/core/lib/Thelia/Model/Category.php +++ b/core/lib/Thelia/Model/Category.php @@ -2,24 +2,9 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseCategory; -use Thelia\Model\CategoryQuery; - - -/** - * Skeleton subclass for representing a row from the 'category' 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 Category extends BaseCategory -{ +use Thelia\Model\Base\Category as BaseCategory; +class Category extends BaseCategory { /** * @return int number of child for the current category */ @@ -57,4 +42,5 @@ class Category extends BaseCategory } + } diff --git a/core/lib/Thelia/Model/CategoryI18n.php b/core/lib/Thelia/Model/CategoryI18n.php old mode 100755 new mode 100644 index cf193e66d..bb4e7b3f3 --- a/core/lib/Thelia/Model/CategoryI18n.php +++ b/core/lib/Thelia/Model/CategoryI18n.php @@ -2,20 +2,8 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseCategoryI18n; +use Thelia\Model\Base\CategoryI18n as BaseCategoryI18n; +class CategoryI18n extends BaseCategoryI18n { -/** - * Skeleton subclass for representing a row from the 'category_i18n' 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 CategoryI18n extends BaseCategoryI18n -{ } diff --git a/core/lib/Thelia/Model/CategoryI18nPeer.php b/core/lib/Thelia/Model/CategoryI18nPeer.php deleted file mode 100755 index 91a8730dd..000000000 --- a/core/lib/Thelia/Model/CategoryI18nPeer.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) + ->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) + ; + + if(!is_null($lang)) { + $this->setLang($lang); + } + + $this->save(); - public function getUsername() { - return $this->getEmail(); } - /** - * {@inheritDoc} - */ - public function eraseCredentials() { - $this->setPassword(null); + public function preInsert(\PropelPDO $con = null) + { + $customerRef = new CustomRefEvent($this); + if (!is_null($this->dispatcher)) { + $this->dispatcher->dispatch(TheliaEvents::CREATECUSTOMER_CUSTOMREF, $customerRef); + } + + $this->setRef($customerRef->hasRef()? $customerRef->getRef() : $this->generateRef()); + + return true; } - /** - * {@inheritDoc} - */ - public function getRoles() { - return array(new Role('USER_CUSTOMER')); + protected function generateRef() + { + return date("YmdHI"); + } + + 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"); + } + + if($password !== null && trim($password) != "") { + $this->setAlgo("PASSWORD_BCRYPT"); + return parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); + } + + } + + public function setDispatcher(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $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 @@ - array('Id', 'ProductId', 'Accessory', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'accessory', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AccessoryTableMap::ID, AccessoryTableMap::PRODUCT_ID, AccessoryTableMap::ACCESSORY, AccessoryTableMap::POSITION, AccessoryTableMap::CREATED_AT, AccessoryTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'ACCESSORY', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'accessory', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Accessory' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'accessory' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(AccessoryTableMap::ID => 0, AccessoryTableMap::PRODUCT_ID => 1, AccessoryTableMap::ACCESSORY => 2, AccessoryTableMap::POSITION => 3, AccessoryTableMap::CREATED_AT => 4, AccessoryTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'ACCESSORY' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'accessory' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AccessoryTableMap::CLASS_DEFAULT : AccessoryTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AccessoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AccessoryTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AccessoryTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AccessoryTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AccessoryTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AccessoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AccessoryTableMap::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; + AccessoryTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AccessoryTableMap::ID); + $criteria->addSelectColumn(AccessoryTableMap::PRODUCT_ID); + $criteria->addSelectColumn(AccessoryTableMap::ACCESSORY); + $criteria->addSelectColumn(AccessoryTableMap::POSITION); + $criteria->addSelectColumn(AccessoryTableMap::CREATED_AT); + $criteria->addSelectColumn(AccessoryTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AccessoryTableMap::DATABASE_NAME)->getTable(AccessoryTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AccessoryTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AccessoryTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AccessoryTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Accessory) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AccessoryTableMap::DATABASE_NAME); + $criteria->add(AccessoryTableMap::ID, (array) $values, Criteria::IN); + } + + $query = AccessoryQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AccessoryTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AccessoryTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the accessory table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AccessoryQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Accessory or Criteria object. + * + * @param mixed $criteria Criteria or Accessory object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AccessoryTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Accessory object + } + + + // Set the correct dbName + $query = AccessoryQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AccessoryTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AccessoryTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AddressTableMap.php b/core/lib/Thelia/Model/Map/AddressTableMap.php new file mode 100644 index 000000000..8a6126964 --- /dev/null +++ b/core/lib/Thelia/Model/Map/AddressTableMap.php @@ -0,0 +1,536 @@ + array('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AddressTableMap::ID, AddressTableMap::TITLE, AddressTableMap::CUSTOMER_ID, AddressTableMap::CUSTOMER_TITLE_ID, AddressTableMap::COMPANY, AddressTableMap::FIRSTNAME, AddressTableMap::LASTNAME, AddressTableMap::ADDRESS1, AddressTableMap::ADDRESS2, AddressTableMap::ADDRESS3, AddressTableMap::ZIPCODE, AddressTableMap::CITY, AddressTableMap::COUNTRY_ID, AddressTableMap::PHONE, AddressTableMap::CREATED_AT, AddressTableMap::UPDATED_AT, ), + self::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', ), + self::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', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::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, ), + self::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, ), + self::TYPE_COLNAME => array(AddressTableMap::ID => 0, AddressTableMap::TITLE => 1, AddressTableMap::CUSTOMER_ID => 2, AddressTableMap::CUSTOMER_TITLE_ID => 3, AddressTableMap::COMPANY => 4, AddressTableMap::FIRSTNAME => 5, AddressTableMap::LASTNAME => 6, AddressTableMap::ADDRESS1 => 7, AddressTableMap::ADDRESS2 => 8, AddressTableMap::ADDRESS3 => 9, AddressTableMap::ZIPCODE => 10, AddressTableMap::CITY => 11, AddressTableMap::COUNTRY_ID => 12, AddressTableMap::PHONE => 13, AddressTableMap::CREATED_AT => 14, AddressTableMap::UPDATED_AT => 15, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AddressTableMap::CLASS_DEFAULT : AddressTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AddressTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AddressTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AddressTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AddressTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AddressTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AddressTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AddressTableMap::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; + AddressTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AddressTableMap::ID); + $criteria->addSelectColumn(AddressTableMap::TITLE); + $criteria->addSelectColumn(AddressTableMap::CUSTOMER_ID); + $criteria->addSelectColumn(AddressTableMap::CUSTOMER_TITLE_ID); + $criteria->addSelectColumn(AddressTableMap::COMPANY); + $criteria->addSelectColumn(AddressTableMap::FIRSTNAME); + $criteria->addSelectColumn(AddressTableMap::LASTNAME); + $criteria->addSelectColumn(AddressTableMap::ADDRESS1); + $criteria->addSelectColumn(AddressTableMap::ADDRESS2); + $criteria->addSelectColumn(AddressTableMap::ADDRESS3); + $criteria->addSelectColumn(AddressTableMap::ZIPCODE); + $criteria->addSelectColumn(AddressTableMap::CITY); + $criteria->addSelectColumn(AddressTableMap::COUNTRY_ID); + $criteria->addSelectColumn(AddressTableMap::PHONE); + $criteria->addSelectColumn(AddressTableMap::CREATED_AT); + $criteria->addSelectColumn(AddressTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AddressTableMap::DATABASE_NAME)->getTable(AddressTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AddressTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AddressTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AddressTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Address) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AddressTableMap::DATABASE_NAME); + $criteria->add(AddressTableMap::ID, (array) $values, Criteria::IN); + } + + $query = AddressQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AddressTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AddressTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the address table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AddressQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Address or Criteria object. + * + * @param mixed $criteria Criteria or Address object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AddressTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Address object + } + + if ($criteria->containsKey(AddressTableMap::ID) && $criteria->keyContainsValue(AddressTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AddressTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AddressQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AddressTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AddressTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AdminGroupTableMap.php b/core/lib/Thelia/Model/Map/AdminGroupTableMap.php new file mode 100644 index 000000000..78f06d1c2 --- /dev/null +++ b/core/lib/Thelia/Model/Map/AdminGroupTableMap.php @@ -0,0 +1,509 @@ + array('Id', 'GroupId', 'AdminId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'groupId', 'adminId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AdminGroupTableMap::ID, AdminGroupTableMap::GROUP_ID, AdminGroupTableMap::ADMIN_ID, AdminGroupTableMap::CREATED_AT, AdminGroupTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'GROUP_ID', 'ADMIN_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'group_id', 'admin_id', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'GroupId' => 1, 'AdminId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'groupId' => 1, 'adminId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AdminGroupTableMap::ID => 0, AdminGroupTableMap::GROUP_ID => 1, AdminGroupTableMap::ADMIN_ID => 2, AdminGroupTableMap::CREATED_AT => 3, AdminGroupTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'GROUP_ID' => 1, 'ADMIN_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'group_id' => 1, 'admin_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\AdminGroup $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getGroupId(), (string) $obj->getAdminId())); + } // if key === null + self::$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 \Thelia\Model\AdminGroup object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AdminGroup object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AdminGroupTableMap::CLASS_DEFAULT : AdminGroupTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AdminGroupTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AdminGroupTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AdminGroupTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AdminGroupTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AdminGroupTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AdminGroupTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AdminGroupTableMap::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; + AdminGroupTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AdminGroupTableMap::ID); + $criteria->addSelectColumn(AdminGroupTableMap::GROUP_ID); + $criteria->addSelectColumn(AdminGroupTableMap::ADMIN_ID); + $criteria->addSelectColumn(AdminGroupTableMap::CREATED_AT); + $criteria->addSelectColumn(AdminGroupTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AdminGroupTableMap::DATABASE_NAME)->getTable(AdminGroupTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AdminGroupTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AdminGroupTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AdminGroupTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\AdminGroup) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AdminGroupTableMap::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(AdminGroupTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(AdminGroupTableMap::GROUP_ID, $value[1])); + $criterion->addAnd($criteria->getNewCriterion(AdminGroupTableMap::ADMIN_ID, $value[2])); + $criteria->addOr($criterion); + } + } + + $query = AdminGroupQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AdminGroupTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AdminGroupTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the admin_group table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AdminGroupQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a AdminGroup or Criteria object. + * + * @param mixed $criteria Criteria or AdminGroup object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from AdminGroup object + } + + if ($criteria->containsKey(AdminGroupTableMap::ID) && $criteria->keyContainsValue(AdminGroupTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminGroupTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AdminGroupQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AdminGroupTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AdminGroupTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AdminLogTableMap.php b/core/lib/Thelia/Model/Map/AdminLogTableMap.php new file mode 100644 index 000000000..633d6b4e9 --- /dev/null +++ b/core/lib/Thelia/Model/Map/AdminLogTableMap.php @@ -0,0 +1,470 @@ + array('Id', 'AdminLogin', 'AdminFirstname', 'AdminLastname', 'Action', 'Request', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'adminLogin', 'adminFirstname', 'adminLastname', 'action', 'request', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AdminLogTableMap::ID, AdminLogTableMap::ADMIN_LOGIN, AdminLogTableMap::ADMIN_FIRSTNAME, AdminLogTableMap::ADMIN_LASTNAME, AdminLogTableMap::ACTION, AdminLogTableMap::REQUEST, AdminLogTableMap::CREATED_AT, AdminLogTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ADMIN_LOGIN', 'ADMIN_FIRSTNAME', 'ADMIN_LASTNAME', 'ACTION', 'REQUEST', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'admin_login', 'admin_firstname', 'admin_lastname', 'action', 'request', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'AdminLogin' => 1, 'AdminFirstname' => 2, 'AdminLastname' => 3, 'Action' => 4, 'Request' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'adminLogin' => 1, 'adminFirstname' => 2, 'adminLastname' => 3, 'action' => 4, 'request' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(AdminLogTableMap::ID => 0, AdminLogTableMap::ADMIN_LOGIN => 1, AdminLogTableMap::ADMIN_FIRSTNAME => 2, AdminLogTableMap::ADMIN_LASTNAME => 3, AdminLogTableMap::ACTION => 4, AdminLogTableMap::REQUEST => 5, AdminLogTableMap::CREATED_AT => 6, AdminLogTableMap::UPDATED_AT => 7, ), + self::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, ), + self::TYPE_FIELDNAME => array('id' => 0, 'admin_login' => 1, 'admin_firstname' => 2, 'admin_lastname' => 3, 'action' => 4, 'request' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AdminLogTableMap::CLASS_DEFAULT : AdminLogTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AdminLogTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AdminLogTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AdminLogTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AdminLogTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AdminLogTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AdminLogTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AdminLogTableMap::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; + AdminLogTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AdminLogTableMap::ID); + $criteria->addSelectColumn(AdminLogTableMap::ADMIN_LOGIN); + $criteria->addSelectColumn(AdminLogTableMap::ADMIN_FIRSTNAME); + $criteria->addSelectColumn(AdminLogTableMap::ADMIN_LASTNAME); + $criteria->addSelectColumn(AdminLogTableMap::ACTION); + $criteria->addSelectColumn(AdminLogTableMap::REQUEST); + $criteria->addSelectColumn(AdminLogTableMap::CREATED_AT); + $criteria->addSelectColumn(AdminLogTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AdminLogTableMap::DATABASE_NAME)->getTable(AdminLogTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AdminLogTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AdminLogTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AdminLogTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\AdminLog) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AdminLogTableMap::DATABASE_NAME); + $criteria->add(AdminLogTableMap::ID, (array) $values, Criteria::IN); + } + + $query = AdminLogQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AdminLogTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AdminLogTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the admin_log table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AdminLogQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a AdminLog or Criteria object. + * + * @param mixed $criteria Criteria or AdminLog object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminLogTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from AdminLog object + } + + if ($criteria->containsKey(AdminLogTableMap::ID) && $criteria->keyContainsValue(AdminLogTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminLogTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AdminLogQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AdminLogTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AdminLogTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AdminTableMap.php b/core/lib/Thelia/Model/Map/AdminTableMap.php new file mode 100644 index 000000000..39decf52c --- /dev/null +++ b/core/lib/Thelia/Model/Map/AdminTableMap.php @@ -0,0 +1,489 @@ + array('Id', 'Firstname', 'Lastname', 'Login', 'Password', 'Algo', 'Salt', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AdminTableMap::ID, AdminTableMap::FIRSTNAME, AdminTableMap::LASTNAME, AdminTableMap::LOGIN, AdminTableMap::PASSWORD, AdminTableMap::ALGO, AdminTableMap::SALT, AdminTableMap::CREATED_AT, AdminTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'FIRSTNAME', 'LASTNAME', 'LOGIN', 'PASSWORD', 'ALGO', 'SALT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Firstname' => 1, 'Lastname' => 2, 'Login' => 3, 'Password' => 4, 'Algo' => 5, 'Salt' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), + self::TYPE_COLNAME => array(AdminTableMap::ID => 0, AdminTableMap::FIRSTNAME => 1, AdminTableMap::LASTNAME => 2, AdminTableMap::LOGIN => 3, AdminTableMap::PASSWORD => 4, AdminTableMap::ALGO => 5, AdminTableMap::SALT => 6, AdminTableMap::CREATED_AT => 7, AdminTableMap::UPDATED_AT => 8, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'FIRSTNAME' => 1, 'LASTNAME' => 2, 'LOGIN' => 3, 'PASSWORD' => 4, 'ALGO' => 5, 'SALT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), + self::TYPE_FIELDNAME => array('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'created_at' => 7, 'updated_at' => 8, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AdminGroupTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AdminTableMap::CLASS_DEFAULT : AdminTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AdminTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AdminTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AdminTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AdminTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AdminTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AdminTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AdminTableMap::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; + AdminTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AdminTableMap::ID); + $criteria->addSelectColumn(AdminTableMap::FIRSTNAME); + $criteria->addSelectColumn(AdminTableMap::LASTNAME); + $criteria->addSelectColumn(AdminTableMap::LOGIN); + $criteria->addSelectColumn(AdminTableMap::PASSWORD); + $criteria->addSelectColumn(AdminTableMap::ALGO); + $criteria->addSelectColumn(AdminTableMap::SALT); + $criteria->addSelectColumn(AdminTableMap::CREATED_AT); + $criteria->addSelectColumn(AdminTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AdminTableMap::DATABASE_NAME)->getTable(AdminTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AdminTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AdminTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AdminTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Admin) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AdminTableMap::DATABASE_NAME); + $criteria->add(AdminTableMap::ID, (array) $values, Criteria::IN); + } + + $query = AdminQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AdminTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AdminTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the admin table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AdminQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Admin or Criteria object. + * + * @param mixed $criteria Criteria or Admin object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Admin object + } + + if ($criteria->containsKey(AdminTableMap::ID) && $criteria->keyContainsValue(AdminTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AdminQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AdminTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AdminTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AreaTableMap.php b/core/lib/Thelia/Model/Map/AreaTableMap.php new file mode 100644 index 000000000..9dc308de5 --- /dev/null +++ b/core/lib/Thelia/Model/Map/AreaTableMap.php @@ -0,0 +1,458 @@ + array('Id', 'Name', 'Unit', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'name', 'unit', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AreaTableMap::ID, AreaTableMap::NAME, AreaTableMap::UNIT, AreaTableMap::CREATED_AT, AreaTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'UNIT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'name', 'unit', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Unit' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AreaTableMap::ID => 0, AreaTableMap::NAME => 1, AreaTableMap::UNIT => 2, AreaTableMap::CREATED_AT => 3, AreaTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'UNIT' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'Countries'); + $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', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CountryTableMap::clearInstancePool(); + DelivzoneTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AreaTableMap::CLASS_DEFAULT : AreaTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AreaTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AreaTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AreaTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AreaTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AreaTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AreaTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AreaTableMap::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; + AreaTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AreaTableMap::ID); + $criteria->addSelectColumn(AreaTableMap::NAME); + $criteria->addSelectColumn(AreaTableMap::UNIT); + $criteria->addSelectColumn(AreaTableMap::CREATED_AT); + $criteria->addSelectColumn(AreaTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AreaTableMap::DATABASE_NAME)->getTable(AreaTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AreaTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AreaTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AreaTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Area) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AreaTableMap::DATABASE_NAME); + $criteria->add(AreaTableMap::ID, (array) $values, Criteria::IN); + } + + $query = AreaQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AreaTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AreaTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the area table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AreaQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Area or Criteria object. + * + * @param mixed $criteria Criteria or Area object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AreaTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Area object + } + + if ($criteria->containsKey(AreaTableMap::ID) && $criteria->keyContainsValue(AreaTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AreaTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AreaQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AreaTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AreaTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php new file mode 100644 index 000000000..14fc79eeb --- /dev/null +++ b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(AttributeAvI18nTableMap::ID, AttributeAvI18nTableMap::LOCALE, AttributeAvI18nTableMap::TITLE, AttributeAvI18nTableMap::DESCRIPTION, AttributeAvI18nTableMap::CHAPO, AttributeAvI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(AttributeAvI18nTableMap::ID => 0, AttributeAvI18nTableMap::LOCALE => 1, AttributeAvI18nTableMap::TITLE => 2, AttributeAvI18nTableMap::DESCRIPTION => 3, AttributeAvI18nTableMap::CHAPO => 4, AttributeAvI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\AttributeAvI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\AttributeAvI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AttributeAvI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AttributeAvI18nTableMap::CLASS_DEFAULT : AttributeAvI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AttributeAvI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AttributeAvI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AttributeAvI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AttributeAvI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AttributeAvI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AttributeAvI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AttributeAvI18nTableMap::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; + AttributeAvI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AttributeAvI18nTableMap::ID); + $criteria->addSelectColumn(AttributeAvI18nTableMap::LOCALE); + $criteria->addSelectColumn(AttributeAvI18nTableMap::TITLE); + $criteria->addSelectColumn(AttributeAvI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(AttributeAvI18nTableMap::CHAPO); + $criteria->addSelectColumn(AttributeAvI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AttributeAvI18nTableMap::DATABASE_NAME)->getTable(AttributeAvI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeAvI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AttributeAvI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AttributeAvI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\AttributeAvI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AttributeAvI18nTableMap::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(AttributeAvI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(AttributeAvI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = AttributeAvI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AttributeAvI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AttributeAvI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the attribute_av_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AttributeAvI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a AttributeAvI18n or Criteria object. + * + * @param mixed $criteria Criteria or AttributeAvI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from AttributeAvI18n object + } + + + // Set the correct dbName + $query = AttributeAvI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AttributeAvI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AttributeAvI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php new file mode 100644 index 000000000..138f0fa9c --- /dev/null +++ b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php @@ -0,0 +1,469 @@ + array('Id', 'AttributeId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AttributeAvTableMap::ID, AttributeAvTableMap::ATTRIBUTE_ID, AttributeAvTableMap::POSITION, AttributeAvTableMap::CREATED_AT, AttributeAvTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'attribute_id', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AttributeAvTableMap::ID => 0, AttributeAvTableMap::ATTRIBUTE_ID => 1, AttributeAvTableMap::POSITION => 2, AttributeAvTableMap::CREATED_AT => 3, AttributeAvTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AttributeCombinationTableMap::clearInstancePool(); + AttributeAvI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AttributeAvTableMap::CLASS_DEFAULT : AttributeAvTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AttributeAvTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AttributeAvTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AttributeAvTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AttributeAvTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AttributeAvTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AttributeAvTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AttributeAvTableMap::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; + AttributeAvTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AttributeAvTableMap::ID); + $criteria->addSelectColumn(AttributeAvTableMap::ATTRIBUTE_ID); + $criteria->addSelectColumn(AttributeAvTableMap::POSITION); + $criteria->addSelectColumn(AttributeAvTableMap::CREATED_AT); + $criteria->addSelectColumn(AttributeAvTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AttributeAvTableMap::DATABASE_NAME)->getTable(AttributeAvTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeAvTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AttributeAvTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AttributeAvTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\AttributeAv) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AttributeAvTableMap::DATABASE_NAME); + $criteria->add(AttributeAvTableMap::ID, (array) $values, Criteria::IN); + } + + $query = AttributeAvQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AttributeAvTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AttributeAvTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the attribute_av table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AttributeAvQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a AttributeAv or Criteria object. + * + * @param mixed $criteria Criteria or AttributeAv object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeAvTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from AttributeAv object + } + + if ($criteria->containsKey(AttributeAvTableMap::ID) && $criteria->keyContainsValue(AttributeAvTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeAvTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AttributeAvQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AttributeAvTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AttributeAvTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php b/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php new file mode 100644 index 000000000..b2525e8c3 --- /dev/null +++ b/core/lib/Thelia/Model/Map/AttributeCategoryTableMap.php @@ -0,0 +1,449 @@ + array('Id', 'CategoryId', 'AttributeId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'attributeId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AttributeCategoryTableMap::ID, AttributeCategoryTableMap::CATEGORY_ID, AttributeCategoryTableMap::ATTRIBUTE_ID, AttributeCategoryTableMap::CREATED_AT, AttributeCategoryTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'ATTRIBUTE_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'category_id', 'attribute_id', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'AttributeId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'attributeId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AttributeCategoryTableMap::ID => 0, AttributeCategoryTableMap::CATEGORY_ID => 1, AttributeCategoryTableMap::ATTRIBUTE_ID => 2, AttributeCategoryTableMap::CREATED_AT => 3, AttributeCategoryTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'ATTRIBUTE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'attribute_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AttributeCategoryTableMap::CLASS_DEFAULT : AttributeCategoryTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AttributeCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AttributeCategoryTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AttributeCategoryTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AttributeCategoryTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AttributeCategoryTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AttributeCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AttributeCategoryTableMap::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; + AttributeCategoryTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AttributeCategoryTableMap::ID); + $criteria->addSelectColumn(AttributeCategoryTableMap::CATEGORY_ID); + $criteria->addSelectColumn(AttributeCategoryTableMap::ATTRIBUTE_ID); + $criteria->addSelectColumn(AttributeCategoryTableMap::CREATED_AT); + $criteria->addSelectColumn(AttributeCategoryTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AttributeCategoryTableMap::DATABASE_NAME)->getTable(AttributeCategoryTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeCategoryTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AttributeCategoryTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AttributeCategoryTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\AttributeCategory) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AttributeCategoryTableMap::DATABASE_NAME); + $criteria->add(AttributeCategoryTableMap::ID, (array) $values, Criteria::IN); + } + + $query = AttributeCategoryQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AttributeCategoryTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AttributeCategoryTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the attribute_category table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AttributeCategoryQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a AttributeCategory or Criteria object. + * + * @param mixed $criteria Criteria or AttributeCategory object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCategoryTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from AttributeCategory object + } + + if ($criteria->containsKey(AttributeCategoryTableMap::ID) && $criteria->keyContainsValue(AttributeCategoryTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCategoryTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AttributeCategoryQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AttributeCategoryTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AttributeCategoryTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php b/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php new file mode 100644 index 000000000..b3e3584a4 --- /dev/null +++ b/core/lib/Thelia/Model/Map/AttributeCombinationTableMap.php @@ -0,0 +1,518 @@ + array('Id', 'AttributeId', 'CombinationId', 'AttributeAvId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'combinationId', 'attributeAvId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AttributeCombinationTableMap::ID, AttributeCombinationTableMap::ATTRIBUTE_ID, AttributeCombinationTableMap::COMBINATION_ID, AttributeCombinationTableMap::ATTRIBUTE_AV_ID, AttributeCombinationTableMap::CREATED_AT, AttributeCombinationTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'COMBINATION_ID', 'ATTRIBUTE_AV_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'attribute_id', 'combination_id', 'attribute_av_id', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'CombinationId' => 2, 'AttributeAvId' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'combinationId' => 2, 'attributeAvId' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(AttributeCombinationTableMap::ID => 0, AttributeCombinationTableMap::ATTRIBUTE_ID => 1, AttributeCombinationTableMap::COMBINATION_ID => 2, AttributeCombinationTableMap::ATTRIBUTE_AV_ID => 3, AttributeCombinationTableMap::CREATED_AT => 4, AttributeCombinationTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'COMBINATION_ID' => 2, 'ATTRIBUTE_AV_ID' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'combination_id' => 2, 'attribute_av_id' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\AttributeCombination $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getAttributeId(), (string) $obj->getCombinationId(), (string) $obj->getAttributeAvId())); + } // if key === null + self::$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 \Thelia\Model\AttributeCombination object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AttributeCombination object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('CombinationId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 3 + $offset : static::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('AttributeId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('CombinationId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 3 + $offset : static::translateFieldName('AttributeAvId', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AttributeCombinationTableMap::CLASS_DEFAULT : AttributeCombinationTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AttributeCombinationTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AttributeCombinationTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AttributeCombinationTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AttributeCombinationTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AttributeCombinationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AttributeCombinationTableMap::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; + AttributeCombinationTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AttributeCombinationTableMap::ID); + $criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_ID); + $criteria->addSelectColumn(AttributeCombinationTableMap::COMBINATION_ID); + $criteria->addSelectColumn(AttributeCombinationTableMap::ATTRIBUTE_AV_ID); + $criteria->addSelectColumn(AttributeCombinationTableMap::CREATED_AT); + $criteria->addSelectColumn(AttributeCombinationTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AttributeCombinationTableMap::DATABASE_NAME)->getTable(AttributeCombinationTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeCombinationTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AttributeCombinationTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AttributeCombinationTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\AttributeCombination) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AttributeCombinationTableMap::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(AttributeCombinationTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_ID, $value[1])); + $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationTableMap::COMBINATION_ID, $value[2])); + $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationTableMap::ATTRIBUTE_AV_ID, $value[3])); + $criteria->addOr($criterion); + } + } + + $query = AttributeCombinationQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AttributeCombinationTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AttributeCombinationTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the attribute_combination table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AttributeCombinationQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a AttributeCombination or Criteria object. + * + * @param mixed $criteria Criteria or AttributeCombination object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeCombinationTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from AttributeCombination object + } + + if ($criteria->containsKey(AttributeCombinationTableMap::ID) && $criteria->keyContainsValue(AttributeCombinationTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCombinationTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AttributeCombinationQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AttributeCombinationTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AttributeCombinationTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php new file mode 100644 index 000000000..b60cae5b8 --- /dev/null +++ b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(AttributeI18nTableMap::ID, AttributeI18nTableMap::LOCALE, AttributeI18nTableMap::TITLE, AttributeI18nTableMap::DESCRIPTION, AttributeI18nTableMap::CHAPO, AttributeI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(AttributeI18nTableMap::ID => 0, AttributeI18nTableMap::LOCALE => 1, AttributeI18nTableMap::TITLE => 2, AttributeI18nTableMap::DESCRIPTION => 3, AttributeI18nTableMap::CHAPO => 4, AttributeI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\AttributeI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\AttributeI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AttributeI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AttributeI18nTableMap::CLASS_DEFAULT : AttributeI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AttributeI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AttributeI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AttributeI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AttributeI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AttributeI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AttributeI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AttributeI18nTableMap::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; + AttributeI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AttributeI18nTableMap::ID); + $criteria->addSelectColumn(AttributeI18nTableMap::LOCALE); + $criteria->addSelectColumn(AttributeI18nTableMap::TITLE); + $criteria->addSelectColumn(AttributeI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(AttributeI18nTableMap::CHAPO); + $criteria->addSelectColumn(AttributeI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AttributeI18nTableMap::DATABASE_NAME)->getTable(AttributeI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AttributeI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AttributeI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\AttributeI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AttributeI18nTableMap::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(AttributeI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(AttributeI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = AttributeI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AttributeI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AttributeI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the attribute_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AttributeI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a AttributeI18n or Criteria object. + * + * @param mixed $criteria Criteria or AttributeI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from AttributeI18n object + } + + + // Set the correct dbName + $query = AttributeI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AttributeI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AttributeI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AttributeTableMap.php b/core/lib/Thelia/Model/Map/AttributeTableMap.php new file mode 100644 index 000000000..dca811cbc --- /dev/null +++ b/core/lib/Thelia/Model/Map/AttributeTableMap.php @@ -0,0 +1,465 @@ + array('Id', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AttributeTableMap::ID, AttributeTableMap::POSITION, AttributeTableMap::CREATED_AT, AttributeTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Position' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'position' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(AttributeTableMap::ID => 0, AttributeTableMap::POSITION => 1, AttributeTableMap::CREATED_AT => 2, AttributeTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'POSITION' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'position' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'AttributeCategories'); + $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', 'Categories'); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AttributeAvTableMap::clearInstancePool(); + AttributeCombinationTableMap::clearInstancePool(); + AttributeCategoryTableMap::clearInstancePool(); + AttributeI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AttributeTableMap::CLASS_DEFAULT : AttributeTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AttributeTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AttributeTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AttributeTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AttributeTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AttributeTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AttributeTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AttributeTableMap::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; + AttributeTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(AttributeTableMap::ID); + $criteria->addSelectColumn(AttributeTableMap::POSITION); + $criteria->addSelectColumn(AttributeTableMap::CREATED_AT); + $criteria->addSelectColumn(AttributeTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(AttributeTableMap::DATABASE_NAME)->getTable(AttributeTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AttributeTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AttributeTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AttributeTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Attribute) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AttributeTableMap::DATABASE_NAME); + $criteria->add(AttributeTableMap::ID, (array) $values, Criteria::IN); + } + + $query = AttributeQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AttributeTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AttributeTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the attribute table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AttributeQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Attribute or Criteria object. + * + * @param mixed $criteria Criteria or Attribute object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AttributeTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Attribute object + } + + if ($criteria->containsKey(AttributeTableMap::ID) && $criteria->keyContainsValue(AttributeTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AttributeQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AttributeTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AttributeTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php new file mode 100644 index 000000000..1611b2ebf --- /dev/null +++ b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(CategoryI18nTableMap::ID, CategoryI18nTableMap::LOCALE, CategoryI18nTableMap::TITLE, CategoryI18nTableMap::DESCRIPTION, CategoryI18nTableMap::CHAPO, CategoryI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(CategoryI18nTableMap::ID => 0, CategoryI18nTableMap::LOCALE => 1, CategoryI18nTableMap::TITLE => 2, CategoryI18nTableMap::DESCRIPTION => 3, CategoryI18nTableMap::CHAPO => 4, CategoryI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CategoryI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\CategoryI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CategoryI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CategoryI18nTableMap::CLASS_DEFAULT : CategoryI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CategoryI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CategoryI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CategoryI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CategoryI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CategoryI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CategoryI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CategoryI18nTableMap::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; + CategoryI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CategoryI18nTableMap::ID); + $criteria->addSelectColumn(CategoryI18nTableMap::LOCALE); + $criteria->addSelectColumn(CategoryI18nTableMap::TITLE); + $criteria->addSelectColumn(CategoryI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(CategoryI18nTableMap::CHAPO); + $criteria->addSelectColumn(CategoryI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CategoryI18nTableMap::DATABASE_NAME)->getTable(CategoryI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CategoryI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CategoryI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CategoryI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CategoryI18nTableMap::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(CategoryI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CategoryI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CategoryI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CategoryI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CategoryI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the category_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CategoryI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CategoryI18n or Criteria object. + * + * @param mixed $criteria Criteria or CategoryI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CategoryI18n object + } + + + // Set the correct dbName + $query = CategoryI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CategoryI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CategoryI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php new file mode 100644 index 000000000..83010e4fa --- /dev/null +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -0,0 +1,526 @@ + array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(CategoryTableMap::ID, CategoryTableMap::PARENT, CategoryTableMap::LINK, CategoryTableMap::VISIBLE, CategoryTableMap::POSITION, CategoryTableMap::CREATED_AT, CategoryTableMap::UPDATED_AT, CategoryTableMap::VERSION, CategoryTableMap::VERSION_CREATED_AT, CategoryTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ), + self::TYPE_COLNAME => array(CategoryTableMap::ID => 0, CategoryTableMap::PARENT => 1, CategoryTableMap::LINK => 2, CategoryTableMap::VISIBLE => 3, CategoryTableMap::POSITION => 4, CategoryTableMap::CREATED_AT => 5, CategoryTableMap::UPDATED_AT => 6, CategoryTableMap::VERSION => 7, CategoryTableMap::VERSION_CREATED_AT => 8, CategoryTableMap::VERSION_CREATED_BY => 9, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'ProductCategories'); + $this->addRelation('FeatureCategory', '\\Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategories'); + $this->addRelation('AttributeCategory', '\\Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategories'); + $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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ProductCategoryTableMap::clearInstancePool(); + FeatureCategoryTableMap::clearInstancePool(); + AttributeCategoryTableMap::clearInstancePool(); + ContentAssocTableMap::clearInstancePool(); + ImageTableMap::clearInstancePool(); + DocumentTableMap::clearInstancePool(); + RewritingTableMap::clearInstancePool(); + CategoryI18nTableMap::clearInstancePool(); + CategoryVersionTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CategoryTableMap::CLASS_DEFAULT : CategoryTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CategoryTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CategoryTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CategoryTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CategoryTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CategoryTableMap::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; + CategoryTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CategoryTableMap::ID); + $criteria->addSelectColumn(CategoryTableMap::PARENT); + $criteria->addSelectColumn(CategoryTableMap::LINK); + $criteria->addSelectColumn(CategoryTableMap::VISIBLE); + $criteria->addSelectColumn(CategoryTableMap::POSITION); + $criteria->addSelectColumn(CategoryTableMap::CREATED_AT); + $criteria->addSelectColumn(CategoryTableMap::UPDATED_AT); + $criteria->addSelectColumn(CategoryTableMap::VERSION); + $criteria->addSelectColumn(CategoryTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(CategoryTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CategoryTableMap::DATABASE_NAME)->getTable(CategoryTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CategoryTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CategoryTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Category) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CategoryTableMap::DATABASE_NAME); + $criteria->add(CategoryTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CategoryQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CategoryTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CategoryTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the category table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CategoryQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Category or Criteria object. + * + * @param mixed $criteria Criteria or Category object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Category object + } + + if ($criteria->containsKey(CategoryTableMap::ID) && $criteria->keyContainsValue(CategoryTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CategoryTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CategoryQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CategoryTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CategoryTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CategoryVersionTableMap.php b/core/lib/Thelia/Model/Map/CategoryVersionTableMap.php new file mode 100644 index 000000000..afaa44e5a --- /dev/null +++ b/core/lib/Thelia/Model/Map/CategoryVersionTableMap.php @@ -0,0 +1,529 @@ + array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(CategoryVersionTableMap::ID, CategoryVersionTableMap::PARENT, CategoryVersionTableMap::LINK, CategoryVersionTableMap::VISIBLE, CategoryVersionTableMap::POSITION, CategoryVersionTableMap::CREATED_AT, CategoryVersionTableMap::UPDATED_AT, CategoryVersionTableMap::VERSION, CategoryVersionTableMap::VERSION_CREATED_AT, CategoryVersionTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ), + self::TYPE_COLNAME => array(CategoryVersionTableMap::ID => 0, CategoryVersionTableMap::PARENT => 1, CategoryVersionTableMap::LINK => 2, CategoryVersionTableMap::VISIBLE => 3, CategoryVersionTableMap::POSITION => 4, CategoryVersionTableMap::CREATED_AT => 5, CategoryVersionTableMap::UPDATED_AT => 6, CategoryVersionTableMap::VERSION => 7, CategoryVersionTableMap::VERSION_CREATED_AT => 8, CategoryVersionTableMap::VERSION_CREATED_BY => 9, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CategoryVersion $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion())); + } // if key === null + self::$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 \Thelia\Model\CategoryVersion object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CategoryVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CategoryVersionTableMap::CLASS_DEFAULT : CategoryVersionTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CategoryVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CategoryVersionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CategoryVersionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CategoryVersionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CategoryVersionTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CategoryVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CategoryVersionTableMap::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; + CategoryVersionTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CategoryVersionTableMap::ID); + $criteria->addSelectColumn(CategoryVersionTableMap::PARENT); + $criteria->addSelectColumn(CategoryVersionTableMap::LINK); + $criteria->addSelectColumn(CategoryVersionTableMap::VISIBLE); + $criteria->addSelectColumn(CategoryVersionTableMap::POSITION); + $criteria->addSelectColumn(CategoryVersionTableMap::CREATED_AT); + $criteria->addSelectColumn(CategoryVersionTableMap::UPDATED_AT); + $criteria->addSelectColumn(CategoryVersionTableMap::VERSION); + $criteria->addSelectColumn(CategoryVersionTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(CategoryVersionTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CategoryVersionTableMap::DATABASE_NAME)->getTable(CategoryVersionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CategoryVersionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CategoryVersionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CategoryVersionTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CategoryVersion) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CategoryVersionTableMap::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(CategoryVersionTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CategoryVersionTableMap::VERSION, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CategoryVersionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CategoryVersionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CategoryVersionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the category_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CategoryVersionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CategoryVersion or Criteria object. + * + * @param mixed $criteria Criteria or CategoryVersion object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CategoryVersionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CategoryVersion object + } + + + // Set the correct dbName + $query = CategoryVersionQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CategoryVersionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CategoryVersionTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CombinationTableMap.php b/core/lib/Thelia/Model/Map/CombinationTableMap.php new file mode 100644 index 000000000..96ce0507e --- /dev/null +++ b/core/lib/Thelia/Model/Map/CombinationTableMap.php @@ -0,0 +1,450 @@ + array('Id', 'Ref', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CombinationTableMap::ID, CombinationTableMap::REF, CombinationTableMap::CREATED_AT, CombinationTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'ref', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(CombinationTableMap::ID => 0, CombinationTableMap::REF => 1, CombinationTableMap::CREATED_AT => 2, CombinationTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AttributeCombinationTableMap::clearInstancePool(); + StockTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CombinationTableMap::CLASS_DEFAULT : CombinationTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CombinationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CombinationTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CombinationTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CombinationTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CombinationTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CombinationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CombinationTableMap::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; + CombinationTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CombinationTableMap::ID); + $criteria->addSelectColumn(CombinationTableMap::REF); + $criteria->addSelectColumn(CombinationTableMap::CREATED_AT); + $criteria->addSelectColumn(CombinationTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.REF'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CombinationTableMap::DATABASE_NAME)->getTable(CombinationTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CombinationTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CombinationTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CombinationTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Combination) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CombinationTableMap::DATABASE_NAME); + $criteria->add(CombinationTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CombinationQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CombinationTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CombinationTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the combination table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CombinationQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Combination or Criteria object. + * + * @param mixed $criteria Criteria or Combination object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CombinationTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Combination object + } + + if ($criteria->containsKey(CombinationTableMap::ID) && $criteria->keyContainsValue(CombinationTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CombinationTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CombinationQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CombinationTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CombinationTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php new file mode 100644 index 000000000..a83f87b76 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ConfigI18nTableMap::ID, ConfigI18nTableMap::LOCALE, ConfigI18nTableMap::TITLE, ConfigI18nTableMap::DESCRIPTION, ConfigI18nTableMap::CHAPO, ConfigI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ConfigI18nTableMap::ID => 0, ConfigI18nTableMap::LOCALE => 1, ConfigI18nTableMap::TITLE => 2, ConfigI18nTableMap::DESCRIPTION => 3, ConfigI18nTableMap::CHAPO => 4, ConfigI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ConfigI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\ConfigI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ConfigI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ConfigI18nTableMap::CLASS_DEFAULT : ConfigI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ConfigI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ConfigI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ConfigI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ConfigI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ConfigI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ConfigI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ConfigI18nTableMap::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; + ConfigI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ConfigI18nTableMap::ID); + $criteria->addSelectColumn(ConfigI18nTableMap::LOCALE); + $criteria->addSelectColumn(ConfigI18nTableMap::TITLE); + $criteria->addSelectColumn(ConfigI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ConfigI18nTableMap::CHAPO); + $criteria->addSelectColumn(ConfigI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ConfigI18nTableMap::DATABASE_NAME)->getTable(ConfigI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ConfigI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ConfigI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ConfigI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ConfigI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ConfigI18nTableMap::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(ConfigI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ConfigI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ConfigI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ConfigI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ConfigI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the config_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ConfigI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ConfigI18n or Criteria object. + * + * @param mixed $criteria Criteria or ConfigI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ConfigI18n object + } + + + // Set the correct dbName + $query = ConfigI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ConfigI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ConfigI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ConfigTableMap.php b/core/lib/Thelia/Model/Map/ConfigTableMap.php new file mode 100644 index 000000000..8bd68a964 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ConfigTableMap.php @@ -0,0 +1,482 @@ + array('Id', 'Name', 'Value', 'Secured', 'Hidden', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'name', 'value', 'secured', 'hidden', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ConfigTableMap::ID, ConfigTableMap::NAME, ConfigTableMap::VALUE, ConfigTableMap::SECURED, ConfigTableMap::HIDDEN, ConfigTableMap::CREATED_AT, ConfigTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'VALUE', 'SECURED', 'HIDDEN', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'name', 'value', 'secured', 'hidden', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Value' => 2, 'Secured' => 3, 'Hidden' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'value' => 2, 'secured' => 3, 'hidden' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(ConfigTableMap::ID => 0, ConfigTableMap::NAME => 1, ConfigTableMap::VALUE => 2, ConfigTableMap::SECURED => 3, ConfigTableMap::HIDDEN => 4, ConfigTableMap::CREATED_AT => 5, ConfigTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'VALUE' => 2, 'SECURED' => 3, 'HIDDEN' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'value' => 2, 'secured' => 3, 'hidden' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ConfigI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ConfigTableMap::CLASS_DEFAULT : ConfigTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ConfigTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ConfigTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ConfigTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ConfigTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ConfigTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ConfigTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ConfigTableMap::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; + ConfigTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ConfigTableMap::ID); + $criteria->addSelectColumn(ConfigTableMap::NAME); + $criteria->addSelectColumn(ConfigTableMap::VALUE); + $criteria->addSelectColumn(ConfigTableMap::SECURED); + $criteria->addSelectColumn(ConfigTableMap::HIDDEN); + $criteria->addSelectColumn(ConfigTableMap::CREATED_AT); + $criteria->addSelectColumn(ConfigTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ConfigTableMap::DATABASE_NAME)->getTable(ConfigTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ConfigTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ConfigTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ConfigTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Config) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ConfigTableMap::DATABASE_NAME); + $criteria->add(ConfigTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ConfigQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ConfigTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ConfigTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the config table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ConfigQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Config or Criteria object. + * + * @param mixed $criteria Criteria or Config object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Config object + } + + if ($criteria->containsKey(ConfigTableMap::ID) && $criteria->keyContainsValue(ConfigTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConfigTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ConfigQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ConfigTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ConfigTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentAssocTableMap.php b/core/lib/Thelia/Model/Map/ContentAssocTableMap.php new file mode 100644 index 000000000..b080bea83 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ContentAssocTableMap.php @@ -0,0 +1,465 @@ + array('Id', 'CategoryId', 'ProductId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'categoryId', 'productId', 'contentId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ContentAssocTableMap::ID, ContentAssocTableMap::CATEGORY_ID, ContentAssocTableMap::PRODUCT_ID, ContentAssocTableMap::CONTENT_ID, ContentAssocTableMap::POSITION, ContentAssocTableMap::CREATED_AT, ContentAssocTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CATEGORY_ID', 'PRODUCT_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'category_id', 'product_id', 'content_id', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'CategoryId' => 1, 'ProductId' => 2, 'ContentId' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'categoryId' => 1, 'productId' => 2, 'contentId' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(ContentAssocTableMap::ID => 0, ContentAssocTableMap::CATEGORY_ID => 1, ContentAssocTableMap::PRODUCT_ID => 2, ContentAssocTableMap::CONTENT_ID => 3, ContentAssocTableMap::POSITION => 4, ContentAssocTableMap::CREATED_AT => 5, ContentAssocTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CATEGORY_ID' => 1, 'PRODUCT_ID' => 2, 'CONTENT_ID' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'category_id' => 1, 'product_id' => 2, 'content_id' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ContentAssocTableMap::CLASS_DEFAULT : ContentAssocTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ContentAssocTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ContentAssocTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ContentAssocTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ContentAssocTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ContentAssocTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ContentAssocTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ContentAssocTableMap::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; + ContentAssocTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ContentAssocTableMap::ID); + $criteria->addSelectColumn(ContentAssocTableMap::CATEGORY_ID); + $criteria->addSelectColumn(ContentAssocTableMap::PRODUCT_ID); + $criteria->addSelectColumn(ContentAssocTableMap::CONTENT_ID); + $criteria->addSelectColumn(ContentAssocTableMap::POSITION); + $criteria->addSelectColumn(ContentAssocTableMap::CREATED_AT); + $criteria->addSelectColumn(ContentAssocTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ContentAssocTableMap::DATABASE_NAME)->getTable(ContentAssocTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentAssocTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ContentAssocTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ContentAssocTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ContentAssoc) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ContentAssocTableMap::DATABASE_NAME); + $criteria->add(ContentAssocTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ContentAssocQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ContentAssocTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ContentAssocTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the content_assoc table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ContentAssocQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ContentAssoc or Criteria object. + * + * @param mixed $criteria Criteria or ContentAssoc object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentAssocTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ContentAssoc object + } + + if ($criteria->containsKey(ContentAssocTableMap::ID) && $criteria->keyContainsValue(ContentAssocTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentAssocTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ContentAssocQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ContentAssocTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ContentAssocTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentFolderTableMap.php b/core/lib/Thelia/Model/Map/ContentFolderTableMap.php new file mode 100644 index 000000000..4fedae441 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ContentFolderTableMap.php @@ -0,0 +1,496 @@ + array('ContentId', 'FolderId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('contentId', 'folderId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID, ContentFolderTableMap::FOLDER_ID, ContentFolderTableMap::CREATED_AT, ContentFolderTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('CONTENT_ID', 'FOLDER_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('content_id', 'folder_id', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('ContentId' => 0, 'FolderId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('contentId' => 0, 'folderId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(ContentFolderTableMap::CONTENT_ID => 0, ContentFolderTableMap::FOLDER_ID => 1, ContentFolderTableMap::CREATED_AT => 2, ContentFolderTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('CONTENT_ID' => 0, 'FOLDER_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('content_id' => 0, 'folder_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ContentFolder $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getContentId(), (string) $obj->getFolderId())); + } // if key === null + self::$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 \Thelia\Model\ContentFolder object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ContentFolder object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ContentId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('FolderId', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ContentFolderTableMap::CLASS_DEFAULT : ContentFolderTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ContentFolderTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ContentFolderTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ContentFolderTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ContentFolderTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ContentFolderTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ContentFolderTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ContentFolderTableMap::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; + ContentFolderTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ContentFolderTableMap::CONTENT_ID); + $criteria->addSelectColumn(ContentFolderTableMap::FOLDER_ID); + $criteria->addSelectColumn(ContentFolderTableMap::CREATED_AT); + $criteria->addSelectColumn(ContentFolderTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ContentFolderTableMap::DATABASE_NAME)->getTable(ContentFolderTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentFolderTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ContentFolderTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ContentFolderTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ContentFolder) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ContentFolderTableMap::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(ContentFolderTableMap::CONTENT_ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ContentFolderTableMap::FOLDER_ID, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ContentFolderQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ContentFolderTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ContentFolderTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the content_folder table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ContentFolderQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ContentFolder or Criteria object. + * + * @param mixed $criteria Criteria or ContentFolder object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentFolderTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ContentFolder object + } + + + // Set the correct dbName + $query = ContentFolderQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ContentFolderTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ContentFolderTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php new file mode 100644 index 000000000..ee9122a6c --- /dev/null +++ b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ContentI18nTableMap::ID, ContentI18nTableMap::LOCALE, ContentI18nTableMap::TITLE, ContentI18nTableMap::DESCRIPTION, ContentI18nTableMap::CHAPO, ContentI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ContentI18nTableMap::ID => 0, ContentI18nTableMap::LOCALE => 1, ContentI18nTableMap::TITLE => 2, ContentI18nTableMap::DESCRIPTION => 3, ContentI18nTableMap::CHAPO => 4, ContentI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ContentI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\ContentI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ContentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ContentI18nTableMap::CLASS_DEFAULT : ContentI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ContentI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ContentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ContentI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ContentI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ContentI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ContentI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ContentI18nTableMap::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; + ContentI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ContentI18nTableMap::ID); + $criteria->addSelectColumn(ContentI18nTableMap::LOCALE); + $criteria->addSelectColumn(ContentI18nTableMap::TITLE); + $criteria->addSelectColumn(ContentI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ContentI18nTableMap::CHAPO); + $criteria->addSelectColumn(ContentI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ContentI18nTableMap::DATABASE_NAME)->getTable(ContentI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ContentI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ContentI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ContentI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ContentI18nTableMap::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(ContentI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ContentI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ContentI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ContentI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ContentI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the content_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ContentI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ContentI18n or Criteria object. + * + * @param mixed $criteria Criteria or ContentI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ContentI18n object + } + + + // Set the correct dbName + $query = ContentI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ContentI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ContentI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php new file mode 100644 index 000000000..60b04ae36 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -0,0 +1,504 @@ + array('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(ContentTableMap::ID, ContentTableMap::VISIBLE, ContentTableMap::POSITION, ContentTableMap::CREATED_AT, ContentTableMap::UPDATED_AT, ContentTableMap::VERSION, ContentTableMap::VERSION_CREATED_AT, ContentTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, 'Version' => 5, 'VersionCreatedAt' => 6, 'VersionCreatedBy' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, 'version' => 5, 'versionCreatedAt' => 6, 'versionCreatedBy' => 7, ), + self::TYPE_COLNAME => array(ContentTableMap::ID => 0, ContentTableMap::VISIBLE => 1, ContentTableMap::POSITION => 2, ContentTableMap::CREATED_AT => 3, ContentTableMap::UPDATED_AT => 4, ContentTableMap::VERSION => 5, ContentTableMap::VERSION_CREATED_AT => 6, ContentTableMap::VERSION_CREATED_BY => 7, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ContentAssocTableMap::clearInstancePool(); + ImageTableMap::clearInstancePool(); + DocumentTableMap::clearInstancePool(); + RewritingTableMap::clearInstancePool(); + ContentFolderTableMap::clearInstancePool(); + ContentI18nTableMap::clearInstancePool(); + ContentVersionTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ContentTableMap::CLASS_DEFAULT : ContentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ContentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ContentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ContentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ContentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ContentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ContentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ContentTableMap::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; + ContentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ContentTableMap::ID); + $criteria->addSelectColumn(ContentTableMap::VISIBLE); + $criteria->addSelectColumn(ContentTableMap::POSITION); + $criteria->addSelectColumn(ContentTableMap::CREATED_AT); + $criteria->addSelectColumn(ContentTableMap::UPDATED_AT); + $criteria->addSelectColumn(ContentTableMap::VERSION); + $criteria->addSelectColumn(ContentTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(ContentTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ContentTableMap::DATABASE_NAME)->getTable(ContentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ContentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ContentTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Content) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ContentTableMap::DATABASE_NAME); + $criteria->add(ContentTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ContentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ContentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ContentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the content table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ContentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Content or Criteria object. + * + * @param mixed $criteria Criteria or Content object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Content object + } + + if ($criteria->containsKey(ContentTableMap::ID) && $criteria->keyContainsValue(ContentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ContentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ContentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ContentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ContentVersionTableMap.php b/core/lib/Thelia/Model/Map/ContentVersionTableMap.php new file mode 100644 index 000000000..d651d24c9 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ContentVersionTableMap.php @@ -0,0 +1,513 @@ + array('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(ContentVersionTableMap::ID, ContentVersionTableMap::VISIBLE, ContentVersionTableMap::POSITION, ContentVersionTableMap::CREATED_AT, ContentVersionTableMap::UPDATED_AT, ContentVersionTableMap::VERSION, ContentVersionTableMap::VERSION_CREATED_AT, ContentVersionTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, 'Version' => 5, 'VersionCreatedAt' => 6, 'VersionCreatedBy' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, 'version' => 5, 'versionCreatedAt' => 6, 'versionCreatedBy' => 7, ), + self::TYPE_COLNAME => array(ContentVersionTableMap::ID => 0, ContentVersionTableMap::VISIBLE => 1, ContentVersionTableMap::POSITION => 2, ContentVersionTableMap::CREATED_AT => 3, ContentVersionTableMap::UPDATED_AT => 4, ContentVersionTableMap::VERSION => 5, ContentVersionTableMap::VERSION_CREATED_AT => 6, ContentVersionTableMap::VERSION_CREATED_BY => 7, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ContentVersion $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion())); + } // if key === null + self::$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 \Thelia\Model\ContentVersion object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ContentVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 5 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 5 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ContentVersionTableMap::CLASS_DEFAULT : ContentVersionTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ContentVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ContentVersionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ContentVersionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ContentVersionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ContentVersionTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ContentVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ContentVersionTableMap::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; + ContentVersionTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ContentVersionTableMap::ID); + $criteria->addSelectColumn(ContentVersionTableMap::VISIBLE); + $criteria->addSelectColumn(ContentVersionTableMap::POSITION); + $criteria->addSelectColumn(ContentVersionTableMap::CREATED_AT); + $criteria->addSelectColumn(ContentVersionTableMap::UPDATED_AT); + $criteria->addSelectColumn(ContentVersionTableMap::VERSION); + $criteria->addSelectColumn(ContentVersionTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(ContentVersionTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ContentVersionTableMap::DATABASE_NAME)->getTable(ContentVersionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ContentVersionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ContentVersionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ContentVersionTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ContentVersion) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ContentVersionTableMap::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(ContentVersionTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ContentVersionTableMap::VERSION, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ContentVersionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ContentVersionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ContentVersionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the content_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ContentVersionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ContentVersion or Criteria object. + * + * @param mixed $criteria Criteria or ContentVersion object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ContentVersionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ContentVersion object + } + + + // Set the correct dbName + $query = ContentVersionQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ContentVersionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ContentVersionTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php new file mode 100644 index 000000000..cc60b09d2 --- /dev/null +++ b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(CountryI18nTableMap::ID, CountryI18nTableMap::LOCALE, CountryI18nTableMap::TITLE, CountryI18nTableMap::DESCRIPTION, CountryI18nTableMap::CHAPO, CountryI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(CountryI18nTableMap::ID => 0, CountryI18nTableMap::LOCALE => 1, CountryI18nTableMap::TITLE => 2, CountryI18nTableMap::DESCRIPTION => 3, CountryI18nTableMap::CHAPO => 4, CountryI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CountryI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\CountryI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CountryI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CountryI18nTableMap::CLASS_DEFAULT : CountryI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CountryI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CountryI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CountryI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CountryI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CountryI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CountryI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CountryI18nTableMap::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; + CountryI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CountryI18nTableMap::ID); + $criteria->addSelectColumn(CountryI18nTableMap::LOCALE); + $criteria->addSelectColumn(CountryI18nTableMap::TITLE); + $criteria->addSelectColumn(CountryI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(CountryI18nTableMap::CHAPO); + $criteria->addSelectColumn(CountryI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CountryI18nTableMap::DATABASE_NAME)->getTable(CountryI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CountryI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CountryI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CountryI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CountryI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CountryI18nTableMap::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(CountryI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CountryI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CountryI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CountryI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CountryI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the country_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CountryI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CountryI18n or Criteria object. + * + * @param mixed $criteria Criteria or CountryI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CountryI18n object + } + + + // Set the correct dbName + $query = CountryI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CountryI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CountryI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php new file mode 100644 index 000000000..c4b96c8bd --- /dev/null +++ b/core/lib/Thelia/Model/Map/CountryTableMap.php @@ -0,0 +1,481 @@ + array('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CountryTableMap::ID, CountryTableMap::AREA_ID, CountryTableMap::ISOCODE, CountryTableMap::ISOALPHA2, CountryTableMap::ISOALPHA3, CountryTableMap::CREATED_AT, CountryTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(CountryTableMap::ID => 0, CountryTableMap::AREA_ID => 1, CountryTableMap::ISOCODE => 2, CountryTableMap::ISOALPHA2 => 3, CountryTableMap::ISOALPHA3 => 4, CountryTableMap::CREATED_AT => 5, CountryTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'TaxRuleCountries'); + $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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + TaxRuleCountryTableMap::clearInstancePool(); + CountryI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CountryTableMap::CLASS_DEFAULT : CountryTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CountryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CountryTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CountryTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CountryTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CountryTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CountryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CountryTableMap::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; + CountryTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CountryTableMap::ID); + $criteria->addSelectColumn(CountryTableMap::AREA_ID); + $criteria->addSelectColumn(CountryTableMap::ISOCODE); + $criteria->addSelectColumn(CountryTableMap::ISOALPHA2); + $criteria->addSelectColumn(CountryTableMap::ISOALPHA3); + $criteria->addSelectColumn(CountryTableMap::CREATED_AT); + $criteria->addSelectColumn(CountryTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CountryTableMap::DATABASE_NAME)->getTable(CountryTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CountryTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CountryTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CountryTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Country) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CountryTableMap::DATABASE_NAME); + $criteria->add(CountryTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CountryQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CountryTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CountryTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the country table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CountryQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Country or Criteria object. + * + * @param mixed $criteria Criteria or Country object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CountryTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Country object + } + + + // Set the correct dbName + $query = CountryQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CountryTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CountryTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CouponOrderTableMap.php b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php new file mode 100644 index 000000000..9d91ef068 --- /dev/null +++ b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php @@ -0,0 +1,455 @@ + array('Id', 'OrderId', 'Code', 'Value', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'code', 'value', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CouponOrderTableMap::ID, CouponOrderTableMap::ORDER_ID, CouponOrderTableMap::CODE, CouponOrderTableMap::VALUE, CouponOrderTableMap::CREATED_AT, CouponOrderTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'CODE', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_id', 'code', 'value', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'Code' => 2, 'Value' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'code' => 2, 'value' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(CouponOrderTableMap::ID => 0, CouponOrderTableMap::ORDER_ID => 1, CouponOrderTableMap::CODE => 2, CouponOrderTableMap::VALUE => 3, CouponOrderTableMap::CREATED_AT => 4, CouponOrderTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'CODE' => 2, 'VALUE' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'code' => 2, 'value' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CouponOrderTableMap::CLASS_DEFAULT : CouponOrderTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CouponOrderTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CouponOrderTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CouponOrderTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CouponOrderTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CouponOrderTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CouponOrderTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CouponOrderTableMap::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; + CouponOrderTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CouponOrderTableMap::ID); + $criteria->addSelectColumn(CouponOrderTableMap::ORDER_ID); + $criteria->addSelectColumn(CouponOrderTableMap::CODE); + $criteria->addSelectColumn(CouponOrderTableMap::VALUE); + $criteria->addSelectColumn(CouponOrderTableMap::CREATED_AT); + $criteria->addSelectColumn(CouponOrderTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CouponOrderTableMap::DATABASE_NAME)->getTable(CouponOrderTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponOrderTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CouponOrderTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CouponOrderTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CouponOrder) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CouponOrderTableMap::DATABASE_NAME); + $criteria->add(CouponOrderTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CouponOrderQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CouponOrderTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CouponOrderTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the coupon_order table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CouponOrderQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CouponOrder or Criteria object. + * + * @param mixed $criteria Criteria or CouponOrder object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CouponOrder object + } + + if ($criteria->containsKey(CouponOrderTableMap::ID) && $criteria->keyContainsValue(CouponOrderTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponOrderTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CouponOrderQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CouponOrderTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CouponOrderTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CouponRuleTableMap.php b/core/lib/Thelia/Model/Map/CouponRuleTableMap.php new file mode 100644 index 000000000..99faeac59 --- /dev/null +++ b/core/lib/Thelia/Model/Map/CouponRuleTableMap.php @@ -0,0 +1,463 @@ + array('Id', 'CouponId', 'Controller', 'Operation', 'Value', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'couponId', 'controller', 'operation', 'value', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CouponRuleTableMap::ID, CouponRuleTableMap::COUPON_ID, CouponRuleTableMap::CONTROLLER, CouponRuleTableMap::OPERATION, CouponRuleTableMap::VALUE, CouponRuleTableMap::CREATED_AT, CouponRuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'COUPON_ID', 'CONTROLLER', 'OPERATION', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'coupon_id', 'controller', 'operation', 'value', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'CouponId' => 1, 'Controller' => 2, 'Operation' => 3, 'Value' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'couponId' => 1, 'controller' => 2, 'operation' => 3, 'value' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(CouponRuleTableMap::ID => 0, CouponRuleTableMap::COUPON_ID => 1, CouponRuleTableMap::CONTROLLER => 2, CouponRuleTableMap::OPERATION => 3, CouponRuleTableMap::VALUE => 4, CouponRuleTableMap::CREATED_AT => 5, CouponRuleTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'COUPON_ID' => 1, 'CONTROLLER' => 2, 'OPERATION' => 3, 'VALUE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'coupon_id' => 1, 'controller' => 2, 'operation' => 3, 'value' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CouponRuleTableMap::CLASS_DEFAULT : CouponRuleTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CouponRuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CouponRuleTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CouponRuleTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CouponRuleTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CouponRuleTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CouponRuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CouponRuleTableMap::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; + CouponRuleTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CouponRuleTableMap::ID); + $criteria->addSelectColumn(CouponRuleTableMap::COUPON_ID); + $criteria->addSelectColumn(CouponRuleTableMap::CONTROLLER); + $criteria->addSelectColumn(CouponRuleTableMap::OPERATION); + $criteria->addSelectColumn(CouponRuleTableMap::VALUE); + $criteria->addSelectColumn(CouponRuleTableMap::CREATED_AT); + $criteria->addSelectColumn(CouponRuleTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CouponRuleTableMap::DATABASE_NAME)->getTable(CouponRuleTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponRuleTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CouponRuleTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CouponRuleTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CouponRule) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CouponRuleTableMap::DATABASE_NAME); + $criteria->add(CouponRuleTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CouponRuleQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CouponRuleTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CouponRuleTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the coupon_rule table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CouponRuleQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CouponRule or Criteria object. + * + * @param mixed $criteria Criteria or CouponRule object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponRuleTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CouponRule object + } + + if ($criteria->containsKey(CouponRuleTableMap::ID) && $criteria->keyContainsValue(CouponRuleTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponRuleTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CouponRuleQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CouponRuleTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CouponRuleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CouponTableMap.php b/core/lib/Thelia/Model/Map/CouponTableMap.php new file mode 100644 index 000000000..d1ff79ac0 --- /dev/null +++ b/core/lib/Thelia/Model/Map/CouponTableMap.php @@ -0,0 +1,496 @@ + array('Id', 'Code', 'Action', 'Value', 'Used', 'AvailableSince', 'DateLimit', 'Activate', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'action', 'value', 'used', 'availableSince', 'dateLimit', 'activate', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CouponTableMap::ID, CouponTableMap::CODE, CouponTableMap::ACTION, CouponTableMap::VALUE, CouponTableMap::USED, CouponTableMap::AVAILABLE_SINCE, CouponTableMap::DATE_LIMIT, CouponTableMap::ACTIVATE, CouponTableMap::CREATED_AT, CouponTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'ACTION', 'VALUE', 'USED', 'AVAILABLE_SINCE', 'DATE_LIMIT', 'ACTIVATE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'action', 'value', 'used', 'available_since', 'date_limit', 'activate', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Action' => 2, 'Value' => 3, 'Used' => 4, 'AvailableSince' => 5, 'DateLimit' => 6, 'Activate' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'availableSince' => 5, 'dateLimit' => 6, 'activate' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), + self::TYPE_COLNAME => array(CouponTableMap::ID => 0, CouponTableMap::CODE => 1, CouponTableMap::ACTION => 2, CouponTableMap::VALUE => 3, CouponTableMap::USED => 4, CouponTableMap::AVAILABLE_SINCE => 5, CouponTableMap::DATE_LIMIT => 6, CouponTableMap::ACTIVATE => 7, CouponTableMap::CREATED_AT => 8, CouponTableMap::UPDATED_AT => 9, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CouponRuleTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CouponTableMap::CLASS_DEFAULT : CouponTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CouponTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CouponTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CouponTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CouponTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CouponTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CouponTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CouponTableMap::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; + CouponTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CouponTableMap::ID); + $criteria->addSelectColumn(CouponTableMap::CODE); + $criteria->addSelectColumn(CouponTableMap::ACTION); + $criteria->addSelectColumn(CouponTableMap::VALUE); + $criteria->addSelectColumn(CouponTableMap::USED); + $criteria->addSelectColumn(CouponTableMap::AVAILABLE_SINCE); + $criteria->addSelectColumn(CouponTableMap::DATE_LIMIT); + $criteria->addSelectColumn(CouponTableMap::ACTIVATE); + $criteria->addSelectColumn(CouponTableMap::CREATED_AT); + $criteria->addSelectColumn(CouponTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CouponTableMap::DATABASE_NAME)->getTable(CouponTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CouponTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CouponTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Coupon) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CouponTableMap::DATABASE_NAME); + $criteria->add(CouponTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CouponQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CouponTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CouponTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the coupon table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CouponQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Coupon or Criteria object. + * + * @param mixed $criteria Criteria or Coupon object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Coupon object + } + + if ($criteria->containsKey(CouponTableMap::ID) && $criteria->keyContainsValue(CouponTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CouponQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CouponTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CouponTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CurrencyTableMap.php b/core/lib/Thelia/Model/Map/CurrencyTableMap.php new file mode 100644 index 000000000..36ed58310 --- /dev/null +++ b/core/lib/Thelia/Model/Map/CurrencyTableMap.php @@ -0,0 +1,480 @@ + array('Id', 'Name', 'Code', 'Symbol', 'Rate', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'name', 'code', 'symbol', 'rate', 'byDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CurrencyTableMap::ID, CurrencyTableMap::NAME, CurrencyTableMap::CODE, CurrencyTableMap::SYMBOL, CurrencyTableMap::RATE, CurrencyTableMap::BY_DEFAULT, CurrencyTableMap::CREATED_AT, CurrencyTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'CODE', 'SYMBOL', 'RATE', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'name', 'code', 'symbol', 'rate', 'by_default', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Code' => 2, 'Symbol' => 3, 'Rate' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(CurrencyTableMap::ID => 0, CurrencyTableMap::NAME => 1, CurrencyTableMap::CODE => 2, CurrencyTableMap::SYMBOL => 3, CurrencyTableMap::RATE => 4, CurrencyTableMap::BY_DEFAULT => 5, CurrencyTableMap::CREATED_AT => 6, CurrencyTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'CODE' => 2, 'SYMBOL' => 3, 'RATE' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + OrderTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CurrencyTableMap::CLASS_DEFAULT : CurrencyTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CurrencyTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CurrencyTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CurrencyTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CurrencyTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CurrencyTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CurrencyTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CurrencyTableMap::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; + CurrencyTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CurrencyTableMap::ID); + $criteria->addSelectColumn(CurrencyTableMap::NAME); + $criteria->addSelectColumn(CurrencyTableMap::CODE); + $criteria->addSelectColumn(CurrencyTableMap::SYMBOL); + $criteria->addSelectColumn(CurrencyTableMap::RATE); + $criteria->addSelectColumn(CurrencyTableMap::BY_DEFAULT); + $criteria->addSelectColumn(CurrencyTableMap::CREATED_AT); + $criteria->addSelectColumn(CurrencyTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CurrencyTableMap::DATABASE_NAME)->getTable(CurrencyTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CurrencyTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CurrencyTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CurrencyTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Currency) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CurrencyTableMap::DATABASE_NAME); + $criteria->add(CurrencyTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CurrencyQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CurrencyTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CurrencyTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the currency table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CurrencyQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Currency or Criteria object. + * + * @param mixed $criteria Criteria or Currency object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CurrencyTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Currency object + } + + if ($criteria->containsKey(CurrencyTableMap::ID) && $criteria->keyContainsValue(CurrencyTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CurrencyTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CurrencyQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CurrencyTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CurrencyTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CustomerTableMap.php b/core/lib/Thelia/Model/Map/CustomerTableMap.php new file mode 100644 index 000000000..030d233d9 --- /dev/null +++ b/core/lib/Thelia/Model/Map/CustomerTableMap.php @@ -0,0 +1,611 @@ + 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', ), + self::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', ), + self::TYPE_COLNAME => array(CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::CUSTOMER_TITLE_ID, CustomerTableMap::COMPANY, CustomerTableMap::FIRSTNAME, CustomerTableMap::LASTNAME, CustomerTableMap::ADDRESS1, CustomerTableMap::ADDRESS2, CustomerTableMap::ADDRESS3, CustomerTableMap::ZIPCODE, CustomerTableMap::CITY, CustomerTableMap::COUNTRY_ID, CustomerTableMap::PHONE, CustomerTableMap::CELLPHONE, CustomerTableMap::EMAIL, CustomerTableMap::PASSWORD, CustomerTableMap::ALGO, CustomerTableMap::SALT, CustomerTableMap::RESELLER, CustomerTableMap::LANG, CustomerTableMap::SPONSOR, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, CustomerTableMap::UPDATED_AT, ), + self::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', ), + self::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', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::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, ), + self::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, ), + self::TYPE_COLNAME => array(CustomerTableMap::ID => 0, CustomerTableMap::REF => 1, CustomerTableMap::CUSTOMER_TITLE_ID => 2, CustomerTableMap::COMPANY => 3, CustomerTableMap::FIRSTNAME => 4, CustomerTableMap::LASTNAME => 5, CustomerTableMap::ADDRESS1 => 6, CustomerTableMap::ADDRESS2 => 7, CustomerTableMap::ADDRESS3 => 8, CustomerTableMap::ZIPCODE => 9, CustomerTableMap::CITY => 10, CustomerTableMap::COUNTRY_ID => 11, CustomerTableMap::PHONE => 12, CustomerTableMap::CELLPHONE => 13, CustomerTableMap::EMAIL => 14, CustomerTableMap::PASSWORD => 15, CustomerTableMap::ALGO => 16, CustomerTableMap::SALT => 17, CustomerTableMap::RESELLER => 18, CustomerTableMap::LANG => 19, CustomerTableMap::SPONSOR => 20, CustomerTableMap::DISCOUNT => 21, CustomerTableMap::CREATED_AT => 22, CustomerTableMap::UPDATED_AT => 23, ), + self::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, ), + self::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, ), + self::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, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'Addresses'); + $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', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AddressTableMap::clearInstancePool(); + OrderTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CustomerTableMap::CLASS_DEFAULT : CustomerTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CustomerTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CustomerTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CustomerTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CustomerTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CustomerTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CustomerTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CustomerTableMap::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; + CustomerTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CustomerTableMap::ID); + $criteria->addSelectColumn(CustomerTableMap::REF); + $criteria->addSelectColumn(CustomerTableMap::CUSTOMER_TITLE_ID); + $criteria->addSelectColumn(CustomerTableMap::COMPANY); + $criteria->addSelectColumn(CustomerTableMap::FIRSTNAME); + $criteria->addSelectColumn(CustomerTableMap::LASTNAME); + $criteria->addSelectColumn(CustomerTableMap::ADDRESS1); + $criteria->addSelectColumn(CustomerTableMap::ADDRESS2); + $criteria->addSelectColumn(CustomerTableMap::ADDRESS3); + $criteria->addSelectColumn(CustomerTableMap::ZIPCODE); + $criteria->addSelectColumn(CustomerTableMap::CITY); + $criteria->addSelectColumn(CustomerTableMap::COUNTRY_ID); + $criteria->addSelectColumn(CustomerTableMap::PHONE); + $criteria->addSelectColumn(CustomerTableMap::CELLPHONE); + $criteria->addSelectColumn(CustomerTableMap::EMAIL); + $criteria->addSelectColumn(CustomerTableMap::PASSWORD); + $criteria->addSelectColumn(CustomerTableMap::ALGO); + $criteria->addSelectColumn(CustomerTableMap::SALT); + $criteria->addSelectColumn(CustomerTableMap::RESELLER); + $criteria->addSelectColumn(CustomerTableMap::LANG); + $criteria->addSelectColumn(CustomerTableMap::SPONSOR); + $criteria->addSelectColumn(CustomerTableMap::DISCOUNT); + $criteria->addSelectColumn(CustomerTableMap::CREATED_AT); + $criteria->addSelectColumn(CustomerTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CustomerTableMap::DATABASE_NAME)->getTable(CustomerTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CustomerTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CustomerTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CustomerTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Customer) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CustomerTableMap::DATABASE_NAME); + $criteria->add(CustomerTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CustomerQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CustomerTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CustomerTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the customer table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CustomerQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Customer or Criteria object. + * + * @param mixed $criteria Criteria or Customer object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Customer object + } + + if ($criteria->containsKey(CustomerTableMap::ID) && $criteria->keyContainsValue(CustomerTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CustomerQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CustomerTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CustomerTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php new file mode 100644 index 000000000..d403756fa --- /dev/null +++ b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php @@ -0,0 +1,481 @@ + array('Id', 'Locale', 'Short', 'Long', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'short', 'long', ), + self::TYPE_COLNAME => array(CustomerTitleI18nTableMap::ID, CustomerTitleI18nTableMap::LOCALE, CustomerTitleI18nTableMap::SHORT, CustomerTitleI18nTableMap::LONG, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'SHORT', 'LONG', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'short', 'long', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Short' => 2, 'Long' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'short' => 2, 'long' => 3, ), + self::TYPE_COLNAME => array(CustomerTitleI18nTableMap::ID => 0, CustomerTitleI18nTableMap::LOCALE => 1, CustomerTitleI18nTableMap::SHORT => 2, CustomerTitleI18nTableMap::LONG => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'SHORT' => 2, 'LONG' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'short' => 2, 'long' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null); + $this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\CustomerTitleI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\CustomerTitleI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\CustomerTitleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CustomerTitleI18nTableMap::CLASS_DEFAULT : CustomerTitleI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CustomerTitleI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CustomerTitleI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CustomerTitleI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CustomerTitleI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CustomerTitleI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CustomerTitleI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CustomerTitleI18nTableMap::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; + CustomerTitleI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CustomerTitleI18nTableMap::ID); + $criteria->addSelectColumn(CustomerTitleI18nTableMap::LOCALE); + $criteria->addSelectColumn(CustomerTitleI18nTableMap::SHORT); + $criteria->addSelectColumn(CustomerTitleI18nTableMap::LONG); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.SHORT'); + $criteria->addSelectColumn($alias . '.LONG'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CustomerTitleI18nTableMap::DATABASE_NAME)->getTable(CustomerTitleI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CustomerTitleI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CustomerTitleI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CustomerTitleI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CustomerTitleI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CustomerTitleI18nTableMap::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(CustomerTitleI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(CustomerTitleI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = CustomerTitleI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CustomerTitleI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CustomerTitleI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the customer_title_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CustomerTitleI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CustomerTitleI18n or Criteria object. + * + * @param mixed $criteria Criteria or CustomerTitleI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CustomerTitleI18n object + } + + + // Set the correct dbName + $query = CustomerTitleI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CustomerTitleI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CustomerTitleI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php new file mode 100644 index 000000000..a392ee4dd --- /dev/null +++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php @@ -0,0 +1,469 @@ + array('Id', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'byDefault', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CustomerTitleTableMap::ID, CustomerTitleTableMap::BY_DEFAULT, CustomerTitleTableMap::POSITION, CustomerTitleTableMap::CREATED_AT, CustomerTitleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'by_default', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ByDefault' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'byDefault' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(CustomerTitleTableMap::ID => 0, CustomerTitleTableMap::BY_DEFAULT => 1, CustomerTitleTableMap::POSITION => 2, CustomerTitleTableMap::CREATED_AT => 3, CustomerTitleTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'BY_DEFAULT' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'by_default' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'Addresses'); + $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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'short, long', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + CustomerTableMap::clearInstancePool(); + CustomerTitleI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? CustomerTitleTableMap::CLASS_DEFAULT : CustomerTitleTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = CustomerTitleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CustomerTitleTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + CustomerTitleTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = CustomerTitleTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + CustomerTitleTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = CustomerTitleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CustomerTitleTableMap::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; + CustomerTitleTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(CustomerTitleTableMap::ID); + $criteria->addSelectColumn(CustomerTitleTableMap::BY_DEFAULT); + $criteria->addSelectColumn(CustomerTitleTableMap::POSITION); + $criteria->addSelectColumn(CustomerTitleTableMap::CREATED_AT); + $criteria->addSelectColumn(CustomerTitleTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(CustomerTitleTableMap::DATABASE_NAME)->getTable(CustomerTitleTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CustomerTitleTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CustomerTitleTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CustomerTitleTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\CustomerTitle) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(CustomerTitleTableMap::DATABASE_NAME); + $criteria->add(CustomerTitleTableMap::ID, (array) $values, Criteria::IN); + } + + $query = CustomerTitleQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { CustomerTitleTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { CustomerTitleTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the customer_title table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return CustomerTitleQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a CustomerTitle or Criteria object. + * + * @param mixed $criteria Criteria or CustomerTitle object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CustomerTitleTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from CustomerTitle object + } + + if ($criteria->containsKey(CustomerTitleTableMap::ID) && $criteria->keyContainsValue(CustomerTitleTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerTitleTableMap::ID.')'); + } + + + // Set the correct dbName + $query = CustomerTitleQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // CustomerTitleTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +CustomerTitleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/DelivzoneTableMap.php b/core/lib/Thelia/Model/Map/DelivzoneTableMap.php new file mode 100644 index 000000000..ca7c5fa4d --- /dev/null +++ b/core/lib/Thelia/Model/Map/DelivzoneTableMap.php @@ -0,0 +1,447 @@ + array('Id', 'AreaId', 'Delivery', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'delivery', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(DelivzoneTableMap::ID, DelivzoneTableMap::AREA_ID, DelivzoneTableMap::DELIVERY, DelivzoneTableMap::CREATED_AT, DelivzoneTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'DELIVERY', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'area_id', 'delivery', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Delivery' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'delivery' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(DelivzoneTableMap::ID => 0, DelivzoneTableMap::AREA_ID => 1, DelivzoneTableMap::DELIVERY => 2, DelivzoneTableMap::CREATED_AT => 3, DelivzoneTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'DELIVERY' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'delivery' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? DelivzoneTableMap::CLASS_DEFAULT : DelivzoneTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = DelivzoneTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + DelivzoneTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = DelivzoneTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + DelivzoneTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = DelivzoneTableMap::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; + DelivzoneTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(DelivzoneTableMap::ID); + $criteria->addSelectColumn(DelivzoneTableMap::AREA_ID); + $criteria->addSelectColumn(DelivzoneTableMap::DELIVERY); + $criteria->addSelectColumn(DelivzoneTableMap::CREATED_AT); + $criteria->addSelectColumn(DelivzoneTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME)->getTable(DelivzoneTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(DelivzoneTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new DelivzoneTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Delivzone) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME); + $criteria->add(DelivzoneTableMap::ID, (array) $values, Criteria::IN); + } + + $query = DelivzoneQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { DelivzoneTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { DelivzoneTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the delivzone table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return DelivzoneQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Delivzone or Criteria object. + * + * @param mixed $criteria Criteria or Delivzone object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Delivzone object + } + + if ($criteria->containsKey(DelivzoneTableMap::ID) && $criteria->keyContainsValue(DelivzoneTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.DelivzoneTableMap::ID.')'); + } + + + // Set the correct dbName + $query = DelivzoneQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // DelivzoneTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +DelivzoneTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php new file mode 100644 index 000000000..d0356e8c6 --- /dev/null +++ b/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(DocumentI18nTableMap::ID, DocumentI18nTableMap::LOCALE, DocumentI18nTableMap::TITLE, DocumentI18nTableMap::DESCRIPTION, DocumentI18nTableMap::CHAPO, DocumentI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(DocumentI18nTableMap::ID => 0, DocumentI18nTableMap::LOCALE => 1, DocumentI18nTableMap::TITLE => 2, DocumentI18nTableMap::DESCRIPTION => 3, DocumentI18nTableMap::CHAPO => 4, DocumentI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\DocumentI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\DocumentI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\DocumentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? DocumentI18nTableMap::CLASS_DEFAULT : DocumentI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = DocumentI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = DocumentI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + DocumentI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = DocumentI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + DocumentI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = DocumentI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = DocumentI18nTableMap::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; + DocumentI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(DocumentI18nTableMap::ID); + $criteria->addSelectColumn(DocumentI18nTableMap::LOCALE); + $criteria->addSelectColumn(DocumentI18nTableMap::TITLE); + $criteria->addSelectColumn(DocumentI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(DocumentI18nTableMap::CHAPO); + $criteria->addSelectColumn(DocumentI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(DocumentI18nTableMap::DATABASE_NAME)->getTable(DocumentI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(DocumentI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(DocumentI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new DocumentI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\DocumentI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(DocumentI18nTableMap::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(DocumentI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(DocumentI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = DocumentI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { DocumentI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { DocumentI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the document_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return DocumentI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a DocumentI18n or Criteria object. + * + * @param mixed $criteria Criteria or DocumentI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from DocumentI18n object + } + + + // Set the correct dbName + $query = DocumentI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // DocumentI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +DocumentI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/DocumentTableMap.php b/core/lib/Thelia/Model/Map/DocumentTableMap.php new file mode 100644 index 000000000..50bb37b95 --- /dev/null +++ b/core/lib/Thelia/Model/Map/DocumentTableMap.php @@ -0,0 +1,502 @@ + array('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(DocumentTableMap::ID, DocumentTableMap::PRODUCT_ID, DocumentTableMap::CATEGORY_ID, DocumentTableMap::FOLDER_ID, DocumentTableMap::CONTENT_ID, DocumentTableMap::FILE, DocumentTableMap::POSITION, DocumentTableMap::CREATED_AT, DocumentTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), + self::TYPE_COLNAME => array(DocumentTableMap::ID => 0, DocumentTableMap::PRODUCT_ID => 1, DocumentTableMap::CATEGORY_ID => 2, DocumentTableMap::FOLDER_ID => 3, DocumentTableMap::CONTENT_ID => 4, DocumentTableMap::FILE => 5, DocumentTableMap::POSITION => 6, DocumentTableMap::CREATED_AT => 7, DocumentTableMap::UPDATED_AT => 8, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + DocumentI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? DocumentTableMap::CLASS_DEFAULT : DocumentTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = DocumentTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = DocumentTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + DocumentTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = DocumentTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + DocumentTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = DocumentTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = DocumentTableMap::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; + DocumentTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(DocumentTableMap::ID); + $criteria->addSelectColumn(DocumentTableMap::PRODUCT_ID); + $criteria->addSelectColumn(DocumentTableMap::CATEGORY_ID); + $criteria->addSelectColumn(DocumentTableMap::FOLDER_ID); + $criteria->addSelectColumn(DocumentTableMap::CONTENT_ID); + $criteria->addSelectColumn(DocumentTableMap::FILE); + $criteria->addSelectColumn(DocumentTableMap::POSITION); + $criteria->addSelectColumn(DocumentTableMap::CREATED_AT); + $criteria->addSelectColumn(DocumentTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(DocumentTableMap::DATABASE_NAME)->getTable(DocumentTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(DocumentTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(DocumentTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new DocumentTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Document) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(DocumentTableMap::DATABASE_NAME); + $criteria->add(DocumentTableMap::ID, (array) $values, Criteria::IN); + } + + $query = DocumentQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { DocumentTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { DocumentTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the document table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return DocumentQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Document or Criteria object. + * + * @param mixed $criteria Criteria or Document object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(DocumentTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Document object + } + + if ($criteria->containsKey(DocumentTableMap::ID) && $criteria->keyContainsValue(DocumentTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.DocumentTableMap::ID.')'); + } + + + // Set the correct dbName + $query = DocumentQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // DocumentTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +DocumentTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php new file mode 100644 index 000000000..b3114e7ba --- /dev/null +++ b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(FeatureAvI18nTableMap::ID, FeatureAvI18nTableMap::LOCALE, FeatureAvI18nTableMap::TITLE, FeatureAvI18nTableMap::DESCRIPTION, FeatureAvI18nTableMap::CHAPO, FeatureAvI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(FeatureAvI18nTableMap::ID => 0, FeatureAvI18nTableMap::LOCALE => 1, FeatureAvI18nTableMap::TITLE => 2, FeatureAvI18nTableMap::DESCRIPTION => 3, FeatureAvI18nTableMap::CHAPO => 4, FeatureAvI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\FeatureAvI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\FeatureAvI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FeatureAvI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FeatureAvI18nTableMap::CLASS_DEFAULT : FeatureAvI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FeatureAvI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FeatureAvI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FeatureAvI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FeatureAvI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FeatureAvI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FeatureAvI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FeatureAvI18nTableMap::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; + FeatureAvI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(FeatureAvI18nTableMap::ID); + $criteria->addSelectColumn(FeatureAvI18nTableMap::LOCALE); + $criteria->addSelectColumn(FeatureAvI18nTableMap::TITLE); + $criteria->addSelectColumn(FeatureAvI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(FeatureAvI18nTableMap::CHAPO); + $criteria->addSelectColumn(FeatureAvI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(FeatureAvI18nTableMap::DATABASE_NAME)->getTable(FeatureAvI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureAvI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FeatureAvI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FeatureAvI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FeatureAvI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FeatureAvI18nTableMap::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(FeatureAvI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(FeatureAvI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = FeatureAvI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FeatureAvI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FeatureAvI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the feature_av_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FeatureAvI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FeatureAvI18n or Criteria object. + * + * @param mixed $criteria Criteria or FeatureAvI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FeatureAvI18n object + } + + + // Set the correct dbName + $query = FeatureAvI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FeatureAvI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FeatureAvI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php new file mode 100644 index 000000000..f447f8dc5 --- /dev/null +++ b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php @@ -0,0 +1,461 @@ + array('Id', 'FeatureId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureAvTableMap::ID, FeatureAvTableMap::FEATURE_ID, FeatureAvTableMap::CREATED_AT, FeatureAvTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'feature_id', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(FeatureAvTableMap::ID => 0, FeatureAvTableMap::FEATURE_ID => 1, FeatureAvTableMap::CREATED_AT => 2, FeatureAvTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + FeatureProdTableMap::clearInstancePool(); + FeatureAvI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FeatureAvTableMap::CLASS_DEFAULT : FeatureAvTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FeatureAvTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FeatureAvTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FeatureAvTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FeatureAvTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FeatureAvTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FeatureAvTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FeatureAvTableMap::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; + FeatureAvTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(FeatureAvTableMap::ID); + $criteria->addSelectColumn(FeatureAvTableMap::FEATURE_ID); + $criteria->addSelectColumn(FeatureAvTableMap::CREATED_AT); + $criteria->addSelectColumn(FeatureAvTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.FEATURE_ID'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(FeatureAvTableMap::DATABASE_NAME)->getTable(FeatureAvTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureAvTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FeatureAvTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FeatureAvTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FeatureAv) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FeatureAvTableMap::DATABASE_NAME); + $criteria->add(FeatureAvTableMap::ID, (array) $values, Criteria::IN); + } + + $query = FeatureAvQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FeatureAvTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FeatureAvTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the feature_av table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FeatureAvQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FeatureAv or Criteria object. + * + * @param mixed $criteria Criteria or FeatureAv object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureAvTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FeatureAv object + } + + if ($criteria->containsKey(FeatureAvTableMap::ID) && $criteria->keyContainsValue(FeatureAvTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureAvTableMap::ID.')'); + } + + + // Set the correct dbName + $query = FeatureAvQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FeatureAvTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FeatureAvTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php new file mode 100644 index 000000000..3e20805b6 --- /dev/null +++ b/core/lib/Thelia/Model/Map/FeatureCategoryTableMap.php @@ -0,0 +1,449 @@ + array('Id', 'FeatureId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'categoryId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureCategoryTableMap::ID, FeatureCategoryTableMap::FEATURE_ID, FeatureCategoryTableMap::CATEGORY_ID, FeatureCategoryTableMap::CREATED_AT, FeatureCategoryTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'feature_id', 'category_id', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'CategoryId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'categoryId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(FeatureCategoryTableMap::ID => 0, FeatureCategoryTableMap::FEATURE_ID => 1, FeatureCategoryTableMap::CATEGORY_ID => 2, FeatureCategoryTableMap::CREATED_AT => 3, FeatureCategoryTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'CATEGORY_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'category_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FeatureCategoryTableMap::CLASS_DEFAULT : FeatureCategoryTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FeatureCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FeatureCategoryTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FeatureCategoryTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FeatureCategoryTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FeatureCategoryTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FeatureCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FeatureCategoryTableMap::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; + FeatureCategoryTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(FeatureCategoryTableMap::ID); + $criteria->addSelectColumn(FeatureCategoryTableMap::FEATURE_ID); + $criteria->addSelectColumn(FeatureCategoryTableMap::CATEGORY_ID); + $criteria->addSelectColumn(FeatureCategoryTableMap::CREATED_AT); + $criteria->addSelectColumn(FeatureCategoryTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(FeatureCategoryTableMap::DATABASE_NAME)->getTable(FeatureCategoryTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureCategoryTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FeatureCategoryTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FeatureCategoryTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FeatureCategory) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FeatureCategoryTableMap::DATABASE_NAME); + $criteria->add(FeatureCategoryTableMap::ID, (array) $values, Criteria::IN); + } + + $query = FeatureCategoryQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FeatureCategoryTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FeatureCategoryTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the feature_category table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FeatureCategoryQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FeatureCategory or Criteria object. + * + * @param mixed $criteria Criteria or FeatureCategory object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureCategoryTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FeatureCategory object + } + + if ($criteria->containsKey(FeatureCategoryTableMap::ID) && $criteria->keyContainsValue(FeatureCategoryTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureCategoryTableMap::ID.')'); + } + + + // Set the correct dbName + $query = FeatureCategoryQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FeatureCategoryTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FeatureCategoryTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php new file mode 100644 index 000000000..af0dfc263 --- /dev/null +++ b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(FeatureI18nTableMap::ID, FeatureI18nTableMap::LOCALE, FeatureI18nTableMap::TITLE, FeatureI18nTableMap::DESCRIPTION, FeatureI18nTableMap::CHAPO, FeatureI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(FeatureI18nTableMap::ID => 0, FeatureI18nTableMap::LOCALE => 1, FeatureI18nTableMap::TITLE => 2, FeatureI18nTableMap::DESCRIPTION => 3, FeatureI18nTableMap::CHAPO => 4, FeatureI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\FeatureI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\FeatureI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FeatureI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FeatureI18nTableMap::CLASS_DEFAULT : FeatureI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FeatureI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FeatureI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FeatureI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FeatureI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FeatureI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FeatureI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FeatureI18nTableMap::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; + FeatureI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(FeatureI18nTableMap::ID); + $criteria->addSelectColumn(FeatureI18nTableMap::LOCALE); + $criteria->addSelectColumn(FeatureI18nTableMap::TITLE); + $criteria->addSelectColumn(FeatureI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(FeatureI18nTableMap::CHAPO); + $criteria->addSelectColumn(FeatureI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(FeatureI18nTableMap::DATABASE_NAME)->getTable(FeatureI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FeatureI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FeatureI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FeatureI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FeatureI18nTableMap::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(FeatureI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(FeatureI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = FeatureI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FeatureI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FeatureI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the feature_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FeatureI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FeatureI18n or Criteria object. + * + * @param mixed $criteria Criteria or FeatureI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FeatureI18n object + } + + + // Set the correct dbName + $query = FeatureI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FeatureI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FeatureI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FeatureProdTableMap.php b/core/lib/Thelia/Model/Map/FeatureProdTableMap.php new file mode 100644 index 000000000..9d952afc3 --- /dev/null +++ b/core/lib/Thelia/Model/Map/FeatureProdTableMap.php @@ -0,0 +1,473 @@ + array('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'featureId', 'featureAvId', 'byDefault', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureProdTableMap::ID, FeatureProdTableMap::PRODUCT_ID, FeatureProdTableMap::FEATURE_ID, FeatureProdTableMap::FEATURE_AV_ID, FeatureProdTableMap::BY_DEFAULT, FeatureProdTableMap::POSITION, FeatureProdTableMap::CREATED_AT, FeatureProdTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'feature_id', 'feature_av_id', 'by_default', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'ByDefault' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'byDefault' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(FeatureProdTableMap::ID => 0, FeatureProdTableMap::PRODUCT_ID => 1, FeatureProdTableMap::FEATURE_ID => 2, FeatureProdTableMap::FEATURE_AV_ID => 3, FeatureProdTableMap::BY_DEFAULT => 4, FeatureProdTableMap::POSITION => 5, FeatureProdTableMap::CREATED_AT => 6, FeatureProdTableMap::UPDATED_AT => 7, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FeatureProdTableMap::CLASS_DEFAULT : FeatureProdTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FeatureProdTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FeatureProdTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FeatureProdTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FeatureProdTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FeatureProdTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FeatureProdTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FeatureProdTableMap::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; + FeatureProdTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(FeatureProdTableMap::ID); + $criteria->addSelectColumn(FeatureProdTableMap::PRODUCT_ID); + $criteria->addSelectColumn(FeatureProdTableMap::FEATURE_ID); + $criteria->addSelectColumn(FeatureProdTableMap::FEATURE_AV_ID); + $criteria->addSelectColumn(FeatureProdTableMap::BY_DEFAULT); + $criteria->addSelectColumn(FeatureProdTableMap::POSITION); + $criteria->addSelectColumn(FeatureProdTableMap::CREATED_AT); + $criteria->addSelectColumn(FeatureProdTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(FeatureProdTableMap::DATABASE_NAME)->getTable(FeatureProdTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureProdTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FeatureProdTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FeatureProdTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FeatureProd) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FeatureProdTableMap::DATABASE_NAME); + $criteria->add(FeatureProdTableMap::ID, (array) $values, Criteria::IN); + } + + $query = FeatureProdQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FeatureProdTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FeatureProdTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the feature_prod table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FeatureProdQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FeatureProd or Criteria object. + * + * @param mixed $criteria Criteria or FeatureProd object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureProdTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FeatureProd object + } + + if ($criteria->containsKey(FeatureProdTableMap::ID) && $criteria->keyContainsValue(FeatureProdTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureProdTableMap::ID.')'); + } + + + // Set the correct dbName + $query = FeatureProdQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FeatureProdTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FeatureProdTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php new file mode 100644 index 000000000..8d851559e --- /dev/null +++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php @@ -0,0 +1,473 @@ + array('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureTableMap::ID, FeatureTableMap::VISIBLE, FeatureTableMap::POSITION, FeatureTableMap::CREATED_AT, FeatureTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'visible', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(FeatureTableMap::ID => 0, FeatureTableMap::VISIBLE => 1, FeatureTableMap::POSITION => 2, FeatureTableMap::CREATED_AT => 3, FeatureTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'FeatureCategories'); + $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', 'Categories'); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + FeatureAvTableMap::clearInstancePool(); + FeatureProdTableMap::clearInstancePool(); + FeatureCategoryTableMap::clearInstancePool(); + FeatureI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FeatureTableMap::CLASS_DEFAULT : FeatureTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FeatureTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FeatureTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FeatureTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FeatureTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FeatureTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FeatureTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FeatureTableMap::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; + FeatureTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(FeatureTableMap::ID); + $criteria->addSelectColumn(FeatureTableMap::VISIBLE); + $criteria->addSelectColumn(FeatureTableMap::POSITION); + $criteria->addSelectColumn(FeatureTableMap::CREATED_AT); + $criteria->addSelectColumn(FeatureTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(FeatureTableMap::DATABASE_NAME)->getTable(FeatureTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FeatureTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FeatureTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FeatureTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Feature) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FeatureTableMap::DATABASE_NAME); + $criteria->add(FeatureTableMap::ID, (array) $values, Criteria::IN); + } + + $query = FeatureQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FeatureTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FeatureTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the feature table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FeatureQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Feature or Criteria object. + * + * @param mixed $criteria Criteria or Feature object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FeatureTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Feature object + } + + if ($criteria->containsKey(FeatureTableMap::ID) && $criteria->keyContainsValue(FeatureTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureTableMap::ID.')'); + } + + + // Set the correct dbName + $query = FeatureQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FeatureTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FeatureTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php new file mode 100644 index 000000000..fc85b17ec --- /dev/null +++ b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(FolderI18nTableMap::ID, FolderI18nTableMap::LOCALE, FolderI18nTableMap::TITLE, FolderI18nTableMap::DESCRIPTION, FolderI18nTableMap::CHAPO, FolderI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(FolderI18nTableMap::ID => 0, FolderI18nTableMap::LOCALE => 1, FolderI18nTableMap::TITLE => 2, FolderI18nTableMap::DESCRIPTION => 3, FolderI18nTableMap::CHAPO => 4, FolderI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\FolderI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\FolderI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FolderI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FolderI18nTableMap::CLASS_DEFAULT : FolderI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FolderI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FolderI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FolderI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FolderI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FolderI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FolderI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FolderI18nTableMap::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; + FolderI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(FolderI18nTableMap::ID); + $criteria->addSelectColumn(FolderI18nTableMap::LOCALE); + $criteria->addSelectColumn(FolderI18nTableMap::TITLE); + $criteria->addSelectColumn(FolderI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(FolderI18nTableMap::CHAPO); + $criteria->addSelectColumn(FolderI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(FolderI18nTableMap::DATABASE_NAME)->getTable(FolderI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FolderI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FolderI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FolderI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FolderI18nTableMap::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(FolderI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(FolderI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = FolderI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FolderI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FolderI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the folder_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FolderI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FolderI18n or Criteria object. + * + * @param mixed $criteria Criteria or FolderI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FolderI18n object + } + + + // Set the correct dbName + $query = FolderI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FolderI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FolderI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php new file mode 100644 index 000000000..794e3691c --- /dev/null +++ b/core/lib/Thelia/Model/Map/FolderTableMap.php @@ -0,0 +1,518 @@ + array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(FolderTableMap::ID, FolderTableMap::PARENT, FolderTableMap::LINK, FolderTableMap::VISIBLE, FolderTableMap::POSITION, FolderTableMap::CREATED_AT, FolderTableMap::UPDATED_AT, FolderTableMap::VERSION, FolderTableMap::VERSION_CREATED_AT, FolderTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ), + self::TYPE_COLNAME => array(FolderTableMap::ID => 0, FolderTableMap::PARENT => 1, FolderTableMap::LINK => 2, FolderTableMap::VISIBLE => 3, FolderTableMap::POSITION => 4, FolderTableMap::CREATED_AT => 5, FolderTableMap::UPDATED_AT => 6, FolderTableMap::VERSION => 7, FolderTableMap::VERSION_CREATED_AT => 8, FolderTableMap::VERSION_CREATED_BY => 9, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ImageTableMap::clearInstancePool(); + DocumentTableMap::clearInstancePool(); + RewritingTableMap::clearInstancePool(); + ContentFolderTableMap::clearInstancePool(); + FolderI18nTableMap::clearInstancePool(); + FolderVersionTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FolderTableMap::CLASS_DEFAULT : FolderTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FolderTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FolderTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FolderTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FolderTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FolderTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FolderTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FolderTableMap::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; + FolderTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(FolderTableMap::ID); + $criteria->addSelectColumn(FolderTableMap::PARENT); + $criteria->addSelectColumn(FolderTableMap::LINK); + $criteria->addSelectColumn(FolderTableMap::VISIBLE); + $criteria->addSelectColumn(FolderTableMap::POSITION); + $criteria->addSelectColumn(FolderTableMap::CREATED_AT); + $criteria->addSelectColumn(FolderTableMap::UPDATED_AT); + $criteria->addSelectColumn(FolderTableMap::VERSION); + $criteria->addSelectColumn(FolderTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(FolderTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(FolderTableMap::DATABASE_NAME)->getTable(FolderTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FolderTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FolderTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Folder) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FolderTableMap::DATABASE_NAME); + $criteria->add(FolderTableMap::ID, (array) $values, Criteria::IN); + } + + $query = FolderQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FolderTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FolderTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the folder table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FolderQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Folder or Criteria object. + * + * @param mixed $criteria Criteria or Folder object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Folder object + } + + if ($criteria->containsKey(FolderTableMap::ID) && $criteria->keyContainsValue(FolderTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.FolderTableMap::ID.')'); + } + + + // Set the correct dbName + $query = FolderQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FolderTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FolderTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/FolderVersionTableMap.php b/core/lib/Thelia/Model/Map/FolderVersionTableMap.php new file mode 100644 index 000000000..c686b7da1 --- /dev/null +++ b/core/lib/Thelia/Model/Map/FolderVersionTableMap.php @@ -0,0 +1,529 @@ + array('Id', 'Parent', 'Link', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'parent', 'link', 'visible', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(FolderVersionTableMap::ID, FolderVersionTableMap::PARENT, FolderVersionTableMap::LINK, FolderVersionTableMap::VISIBLE, FolderVersionTableMap::POSITION, FolderVersionTableMap::CREATED_AT, FolderVersionTableMap::UPDATED_AT, FolderVersionTableMap::VERSION, FolderVersionTableMap::VERSION_CREATED_AT, FolderVersionTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'PARENT', 'LINK', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'parent', 'link', 'visible', 'position', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, 'Version' => 7, 'VersionCreatedAt' => 8, 'VersionCreatedBy' => 9, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'parent' => 1, 'link' => 2, 'visible' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, 'version' => 7, 'versionCreatedAt' => 8, 'versionCreatedBy' => 9, ), + self::TYPE_COLNAME => array(FolderVersionTableMap::ID => 0, FolderVersionTableMap::PARENT => 1, FolderVersionTableMap::LINK => 2, FolderVersionTableMap::VISIBLE => 3, FolderVersionTableMap::POSITION => 4, FolderVersionTableMap::CREATED_AT => 5, FolderVersionTableMap::UPDATED_AT => 6, FolderVersionTableMap::VERSION => 7, FolderVersionTableMap::VERSION_CREATED_AT => 8, FolderVersionTableMap::VERSION_CREATED_BY => 9, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\FolderVersion $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion())); + } // if key === null + self::$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 \Thelia\Model\FolderVersion object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\FolderVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 7 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? FolderVersionTableMap::CLASS_DEFAULT : FolderVersionTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = FolderVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = FolderVersionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + FolderVersionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = FolderVersionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + FolderVersionTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = FolderVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = FolderVersionTableMap::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; + FolderVersionTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(FolderVersionTableMap::ID); + $criteria->addSelectColumn(FolderVersionTableMap::PARENT); + $criteria->addSelectColumn(FolderVersionTableMap::LINK); + $criteria->addSelectColumn(FolderVersionTableMap::VISIBLE); + $criteria->addSelectColumn(FolderVersionTableMap::POSITION); + $criteria->addSelectColumn(FolderVersionTableMap::CREATED_AT); + $criteria->addSelectColumn(FolderVersionTableMap::UPDATED_AT); + $criteria->addSelectColumn(FolderVersionTableMap::VERSION); + $criteria->addSelectColumn(FolderVersionTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(FolderVersionTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(FolderVersionTableMap::DATABASE_NAME)->getTable(FolderVersionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(FolderVersionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(FolderVersionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new FolderVersionTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\FolderVersion) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(FolderVersionTableMap::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(FolderVersionTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(FolderVersionTableMap::VERSION, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = FolderVersionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { FolderVersionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { FolderVersionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the folder_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return FolderVersionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a FolderVersion or Criteria object. + * + * @param mixed $criteria Criteria or FolderVersion object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(FolderVersionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from FolderVersion object + } + + + // Set the correct dbName + $query = FolderVersionQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // FolderVersionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +FolderVersionTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php new file mode 100644 index 000000000..585127821 --- /dev/null +++ b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(GroupI18nTableMap::ID, GroupI18nTableMap::LOCALE, GroupI18nTableMap::TITLE, GroupI18nTableMap::DESCRIPTION, GroupI18nTableMap::CHAPO, GroupI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(GroupI18nTableMap::ID => 0, GroupI18nTableMap::LOCALE => 1, GroupI18nTableMap::TITLE => 2, GroupI18nTableMap::DESCRIPTION => 3, GroupI18nTableMap::CHAPO => 4, GroupI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\GroupI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\GroupI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\GroupI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? GroupI18nTableMap::CLASS_DEFAULT : GroupI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = GroupI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = GroupI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + GroupI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = GroupI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + GroupI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = GroupI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = GroupI18nTableMap::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; + GroupI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(GroupI18nTableMap::ID); + $criteria->addSelectColumn(GroupI18nTableMap::LOCALE); + $criteria->addSelectColumn(GroupI18nTableMap::TITLE); + $criteria->addSelectColumn(GroupI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(GroupI18nTableMap::CHAPO); + $criteria->addSelectColumn(GroupI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(GroupI18nTableMap::DATABASE_NAME)->getTable(GroupI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(GroupI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new GroupI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\GroupI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(GroupI18nTableMap::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(GroupI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(GroupI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = GroupI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { GroupI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { GroupI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the group_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return GroupI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a GroupI18n or Criteria object. + * + * @param mixed $criteria Criteria or GroupI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from GroupI18n object + } + + + // Set the correct dbName + $query = GroupI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // GroupI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +GroupI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/GroupModuleTableMap.php b/core/lib/Thelia/Model/Map/GroupModuleTableMap.php new file mode 100644 index 000000000..49361d253 --- /dev/null +++ b/core/lib/Thelia/Model/Map/GroupModuleTableMap.php @@ -0,0 +1,456 @@ + array('Id', 'GroupId', 'ModuleId', 'Access', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'groupId', 'moduleId', 'access', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(GroupModuleTableMap::ID, GroupModuleTableMap::GROUP_ID, GroupModuleTableMap::MODULE_ID, GroupModuleTableMap::ACCESS, GroupModuleTableMap::CREATED_AT, GroupModuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'GROUP_ID', 'MODULE_ID', 'ACCESS', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'group_id', 'module_id', 'access', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'GroupId' => 1, 'ModuleId' => 2, 'Access' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'groupId' => 1, 'moduleId' => 2, 'access' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(GroupModuleTableMap::ID => 0, GroupModuleTableMap::GROUP_ID => 1, GroupModuleTableMap::MODULE_ID => 2, GroupModuleTableMap::ACCESS => 3, GroupModuleTableMap::CREATED_AT => 4, GroupModuleTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'GROUP_ID' => 1, 'MODULE_ID' => 2, 'ACCESS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'group_id' => 1, 'module_id' => 2, 'access' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? GroupModuleTableMap::CLASS_DEFAULT : GroupModuleTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = GroupModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = GroupModuleTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + GroupModuleTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = GroupModuleTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + GroupModuleTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = GroupModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = GroupModuleTableMap::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; + GroupModuleTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(GroupModuleTableMap::ID); + $criteria->addSelectColumn(GroupModuleTableMap::GROUP_ID); + $criteria->addSelectColumn(GroupModuleTableMap::MODULE_ID); + $criteria->addSelectColumn(GroupModuleTableMap::ACCESS); + $criteria->addSelectColumn(GroupModuleTableMap::CREATED_AT); + $criteria->addSelectColumn(GroupModuleTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(GroupModuleTableMap::DATABASE_NAME)->getTable(GroupModuleTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupModuleTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(GroupModuleTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new GroupModuleTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\GroupModule) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(GroupModuleTableMap::DATABASE_NAME); + $criteria->add(GroupModuleTableMap::ID, (array) $values, Criteria::IN); + } + + $query = GroupModuleQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { GroupModuleTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { GroupModuleTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the group_module table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return GroupModuleQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a GroupModule or Criteria object. + * + * @param mixed $criteria Criteria or GroupModule object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from GroupModule object + } + + if ($criteria->containsKey(GroupModuleTableMap::ID) && $criteria->keyContainsValue(GroupModuleTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupModuleTableMap::ID.')'); + } + + + // Set the correct dbName + $query = GroupModuleQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // GroupModuleTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +GroupModuleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/GroupResourceTableMap.php b/core/lib/Thelia/Model/Map/GroupResourceTableMap.php new file mode 100644 index 000000000..9304d8e59 --- /dev/null +++ b/core/lib/Thelia/Model/Map/GroupResourceTableMap.php @@ -0,0 +1,525 @@ + array('Id', 'GroupId', 'ResourceId', 'Read', 'Write', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'groupId', 'resourceId', 'read', 'write', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(GroupResourceTableMap::ID, GroupResourceTableMap::GROUP_ID, GroupResourceTableMap::RESOURCE_ID, GroupResourceTableMap::READ, GroupResourceTableMap::WRITE, GroupResourceTableMap::CREATED_AT, GroupResourceTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'GROUP_ID', 'RESOURCE_ID', 'READ', 'WRITE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'group_id', 'resource_id', 'read', 'write', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'GroupId' => 1, 'ResourceId' => 2, 'Read' => 3, 'Write' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'groupId' => 1, 'resourceId' => 2, 'read' => 3, 'write' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(GroupResourceTableMap::ID => 0, GroupResourceTableMap::GROUP_ID => 1, GroupResourceTableMap::RESOURCE_ID => 2, GroupResourceTableMap::READ => 3, GroupResourceTableMap::WRITE => 4, GroupResourceTableMap::CREATED_AT => 5, GroupResourceTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'GROUP_ID' => 1, 'RESOURCE_ID' => 2, 'READ' => 3, 'WRITE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'group_id' => 1, 'resource_id' => 2, 'read' => 3, 'write' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\GroupResource $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getGroupId(), (string) $obj->getResourceId())); + } // if key === null + self::$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 \Thelia\Model\GroupResource object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\GroupResource object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? GroupResourceTableMap::CLASS_DEFAULT : GroupResourceTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = GroupResourceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = GroupResourceTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + GroupResourceTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = GroupResourceTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + GroupResourceTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = GroupResourceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = GroupResourceTableMap::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; + GroupResourceTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(GroupResourceTableMap::ID); + $criteria->addSelectColumn(GroupResourceTableMap::GROUP_ID); + $criteria->addSelectColumn(GroupResourceTableMap::RESOURCE_ID); + $criteria->addSelectColumn(GroupResourceTableMap::READ); + $criteria->addSelectColumn(GroupResourceTableMap::WRITE); + $criteria->addSelectColumn(GroupResourceTableMap::CREATED_AT); + $criteria->addSelectColumn(GroupResourceTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(GroupResourceTableMap::DATABASE_NAME)->getTable(GroupResourceTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupResourceTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(GroupResourceTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new GroupResourceTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\GroupResource) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(GroupResourceTableMap::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(GroupResourceTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(GroupResourceTableMap::GROUP_ID, $value[1])); + $criterion->addAnd($criteria->getNewCriterion(GroupResourceTableMap::RESOURCE_ID, $value[2])); + $criteria->addOr($criterion); + } + } + + $query = GroupResourceQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { GroupResourceTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { GroupResourceTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the group_resource table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return GroupResourceQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a GroupResource or Criteria object. + * + * @param mixed $criteria Criteria or GroupResource object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from GroupResource object + } + + if ($criteria->containsKey(GroupResourceTableMap::ID) && $criteria->keyContainsValue(GroupResourceTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupResourceTableMap::ID.')'); + } + + + // Set the correct dbName + $query = GroupResourceQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // GroupResourceTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +GroupResourceTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/GroupTableMap.php b/core/lib/Thelia/Model/Map/GroupTableMap.php new file mode 100644 index 000000000..a8c830005 --- /dev/null +++ b/core/lib/Thelia/Model/Map/GroupTableMap.php @@ -0,0 +1,466 @@ + array('Id', 'Code', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(GroupTableMap::ID, GroupTableMap::CODE, GroupTableMap::CREATED_AT, GroupTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(GroupTableMap::ID => 0, GroupTableMap::CODE => 1, GroupTableMap::CREATED_AT => 2, GroupTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AdminGroupTableMap::clearInstancePool(); + GroupResourceTableMap::clearInstancePool(); + GroupModuleTableMap::clearInstancePool(); + GroupI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? GroupTableMap::CLASS_DEFAULT : GroupTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = GroupTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = GroupTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + GroupTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = GroupTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + GroupTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = GroupTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = GroupTableMap::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; + GroupTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(GroupTableMap::ID); + $criteria->addSelectColumn(GroupTableMap::CODE); + $criteria->addSelectColumn(GroupTableMap::CREATED_AT); + $criteria->addSelectColumn(GroupTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CODE'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(GroupTableMap::DATABASE_NAME)->getTable(GroupTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(GroupTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new GroupTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Group) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(GroupTableMap::DATABASE_NAME); + $criteria->add(GroupTableMap::ID, (array) $values, Criteria::IN); + } + + $query = GroupQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { GroupTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { GroupTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the group table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return GroupQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Group or Criteria object. + * + * @param mixed $criteria Criteria or Group object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Group object + } + + if ($criteria->containsKey(GroupTableMap::ID) && $criteria->keyContainsValue(GroupTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupTableMap::ID.')'); + } + + + // Set the correct dbName + $query = GroupQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // GroupTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +GroupTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ImageI18nTableMap.php new file mode 100644 index 000000000..4f3b197a6 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ImageI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ImageI18nTableMap::ID, ImageI18nTableMap::LOCALE, ImageI18nTableMap::TITLE, ImageI18nTableMap::DESCRIPTION, ImageI18nTableMap::CHAPO, ImageI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ImageI18nTableMap::ID => 0, ImageI18nTableMap::LOCALE => 1, ImageI18nTableMap::TITLE => 2, ImageI18nTableMap::DESCRIPTION => 3, ImageI18nTableMap::CHAPO => 4, ImageI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ImageI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\ImageI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ImageI18nTableMap::CLASS_DEFAULT : ImageI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ImageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ImageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ImageI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ImageI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ImageI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ImageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ImageI18nTableMap::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; + ImageI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ImageI18nTableMap::ID); + $criteria->addSelectColumn(ImageI18nTableMap::LOCALE); + $criteria->addSelectColumn(ImageI18nTableMap::TITLE); + $criteria->addSelectColumn(ImageI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ImageI18nTableMap::CHAPO); + $criteria->addSelectColumn(ImageI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ImageI18nTableMap::DATABASE_NAME)->getTable(ImageI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ImageI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ImageI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ImageI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ImageI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ImageI18nTableMap::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(ImageI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ImageI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ImageI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ImageI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ImageI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the image_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ImageI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ImageI18n or Criteria object. + * + * @param mixed $criteria Criteria or ImageI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ImageI18n object + } + + + // Set the correct dbName + $query = ImageI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ImageI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ImageI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ImageTableMap.php b/core/lib/Thelia/Model/Map/ImageTableMap.php new file mode 100644 index 000000000..0f8d82b20 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ImageTableMap.php @@ -0,0 +1,502 @@ + array('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ImageTableMap::ID, ImageTableMap::PRODUCT_ID, ImageTableMap::CATEGORY_ID, ImageTableMap::FOLDER_ID, ImageTableMap::CONTENT_ID, ImageTableMap::FILE, ImageTableMap::POSITION, ImageTableMap::CREATED_AT, ImageTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), + self::TYPE_COLNAME => array(ImageTableMap::ID => 0, ImageTableMap::PRODUCT_ID => 1, ImageTableMap::CATEGORY_ID => 2, ImageTableMap::FOLDER_ID => 3, ImageTableMap::CONTENT_ID => 4, ImageTableMap::FILE => 5, ImageTableMap::POSITION => 6, ImageTableMap::CREATED_AT => 7, ImageTableMap::UPDATED_AT => 8, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ImageI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ImageTableMap::CLASS_DEFAULT : ImageTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ImageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ImageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ImageTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ImageTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ImageTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ImageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ImageTableMap::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; + ImageTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ImageTableMap::ID); + $criteria->addSelectColumn(ImageTableMap::PRODUCT_ID); + $criteria->addSelectColumn(ImageTableMap::CATEGORY_ID); + $criteria->addSelectColumn(ImageTableMap::FOLDER_ID); + $criteria->addSelectColumn(ImageTableMap::CONTENT_ID); + $criteria->addSelectColumn(ImageTableMap::FILE); + $criteria->addSelectColumn(ImageTableMap::POSITION); + $criteria->addSelectColumn(ImageTableMap::CREATED_AT); + $criteria->addSelectColumn(ImageTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ImageTableMap::DATABASE_NAME)->getTable(ImageTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ImageTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ImageTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ImageTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Image) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ImageTableMap::DATABASE_NAME); + $criteria->add(ImageTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ImageQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ImageTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ImageTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the image table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ImageQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Image or Criteria object. + * + * @param mixed $criteria Criteria or Image object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ImageTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Image object + } + + if ($criteria->containsKey(ImageTableMap::ID) && $criteria->keyContainsValue(ImageTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ImageTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ImageQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ImageTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ImageTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/LangTableMap.php b/core/lib/Thelia/Model/Map/LangTableMap.php new file mode 100644 index 000000000..86e3ebe16 --- /dev/null +++ b/core/lib/Thelia/Model/Map/LangTableMap.php @@ -0,0 +1,470 @@ + array('Id', 'Title', 'Code', 'Locale', 'Url', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'title', 'code', 'locale', 'url', 'byDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(LangTableMap::ID, LangTableMap::TITLE, LangTableMap::CODE, LangTableMap::LOCALE, LangTableMap::URL, LangTableMap::BY_DEFAULT, LangTableMap::CREATED_AT, LangTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'TITLE', 'CODE', 'LOCALE', 'URL', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'title', 'code', 'locale', 'url', 'by_default', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Title' => 1, 'Code' => 2, 'Locale' => 3, 'Url' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(LangTableMap::ID => 0, LangTableMap::TITLE => 1, LangTableMap::CODE => 2, LangTableMap::LOCALE => 3, LangTableMap::URL => 4, LangTableMap::BY_DEFAULT => 5, LangTableMap::CREATED_AT => 6, LangTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'TITLE' => 1, 'CODE' => 2, 'LOCALE' => 3, 'URL' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? LangTableMap::CLASS_DEFAULT : LangTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = LangTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = LangTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + LangTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = LangTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + LangTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = LangTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = LangTableMap::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; + LangTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(LangTableMap::ID); + $criteria->addSelectColumn(LangTableMap::TITLE); + $criteria->addSelectColumn(LangTableMap::CODE); + $criteria->addSelectColumn(LangTableMap::LOCALE); + $criteria->addSelectColumn(LangTableMap::URL); + $criteria->addSelectColumn(LangTableMap::BY_DEFAULT); + $criteria->addSelectColumn(LangTableMap::CREATED_AT); + $criteria->addSelectColumn(LangTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(LangTableMap::DATABASE_NAME)->getTable(LangTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(LangTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(LangTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new LangTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Lang) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(LangTableMap::DATABASE_NAME); + $criteria->add(LangTableMap::ID, (array) $values, Criteria::IN); + } + + $query = LangQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { LangTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { LangTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the lang table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return LangQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Lang or Criteria object. + * + * @param mixed $criteria Criteria or Lang object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(LangTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Lang object + } + + if ($criteria->containsKey(LangTableMap::ID) && $criteria->keyContainsValue(LangTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.LangTableMap::ID.')'); + } + + + // Set the correct dbName + $query = LangQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // LangTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +LangTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php new file mode 100644 index 000000000..f084515c0 --- /dev/null +++ b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php @@ -0,0 +1,489 @@ + array('Id', 'Locale', 'Title', 'Description', 'DescriptionHtml', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'descriptionHtml', ), + self::TYPE_COLNAME => array(MessageI18nTableMap::ID, MessageI18nTableMap::LOCALE, MessageI18nTableMap::TITLE, MessageI18nTableMap::DESCRIPTION, MessageI18nTableMap::DESCRIPTION_HTML, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'DESCRIPTION_HTML', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'description_html', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'DescriptionHtml' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'descriptionHtml' => 4, ), + self::TYPE_COLNAME => array(MessageI18nTableMap::ID => 0, MessageI18nTableMap::LOCALE => 1, MessageI18nTableMap::TITLE => 2, MessageI18nTableMap::DESCRIPTION => 3, MessageI18nTableMap::DESCRIPTION_HTML => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'DESCRIPTION_HTML' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'description_html' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\MessageI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\MessageI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\MessageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? MessageI18nTableMap::CLASS_DEFAULT : MessageI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = MessageI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = MessageI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + MessageI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = MessageI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + MessageI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = MessageI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = MessageI18nTableMap::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; + MessageI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(MessageI18nTableMap::ID); + $criteria->addSelectColumn(MessageI18nTableMap::LOCALE); + $criteria->addSelectColumn(MessageI18nTableMap::TITLE); + $criteria->addSelectColumn(MessageI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(MessageI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(MessageI18nTableMap::DATABASE_NAME)->getTable(MessageI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(MessageI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(MessageI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new MessageI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\MessageI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(MessageI18nTableMap::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(MessageI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(MessageI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = MessageI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { MessageI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { MessageI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the message_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return MessageI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a MessageI18n or Criteria object. + * + * @param mixed $criteria Criteria or MessageI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from MessageI18n object + } + + + // Set the correct dbName + $query = MessageI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // MessageI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +MessageI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/MessageTableMap.php b/core/lib/Thelia/Model/Map/MessageTableMap.php new file mode 100644 index 000000000..de2a205f9 --- /dev/null +++ b/core/lib/Thelia/Model/Map/MessageTableMap.php @@ -0,0 +1,501 @@ + array('Id', 'Code', 'Secured', 'Ref', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'secured', 'ref', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(MessageTableMap::ID, MessageTableMap::CODE, MessageTableMap::SECURED, MessageTableMap::REF, MessageTableMap::CREATED_AT, MessageTableMap::UPDATED_AT, MessageTableMap::VERSION, MessageTableMap::VERSION_CREATED_AT, MessageTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'SECURED', 'REF', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'code', 'secured', 'ref', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Secured' => 2, 'Ref' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ), + self::TYPE_COLNAME => array(MessageTableMap::ID => 0, MessageTableMap::CODE => 1, MessageTableMap::SECURED => 2, MessageTableMap::REF => 3, MessageTableMap::CREATED_AT => 4, MessageTableMap::UPDATED_AT => 5, MessageTableMap::VERSION => 6, MessageTableMap::VERSION_CREATED_AT => 7, MessageTableMap::VERSION_CREATED_BY => 8, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, description_html', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + MessageI18nTableMap::clearInstancePool(); + MessageVersionTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? MessageTableMap::CLASS_DEFAULT : MessageTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = MessageTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = MessageTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + MessageTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = MessageTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + MessageTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = MessageTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = MessageTableMap::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; + MessageTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(MessageTableMap::ID); + $criteria->addSelectColumn(MessageTableMap::CODE); + $criteria->addSelectColumn(MessageTableMap::SECURED); + $criteria->addSelectColumn(MessageTableMap::REF); + $criteria->addSelectColumn(MessageTableMap::CREATED_AT); + $criteria->addSelectColumn(MessageTableMap::UPDATED_AT); + $criteria->addSelectColumn(MessageTableMap::VERSION); + $criteria->addSelectColumn(MessageTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(MessageTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(MessageTableMap::DATABASE_NAME)->getTable(MessageTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(MessageTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(MessageTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new MessageTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Message) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(MessageTableMap::DATABASE_NAME); + $criteria->add(MessageTableMap::ID, (array) $values, Criteria::IN); + } + + $query = MessageQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { MessageTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { MessageTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the message table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return MessageQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Message or Criteria object. + * + * @param mixed $criteria Criteria or Message object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Message object + } + + if ($criteria->containsKey(MessageTableMap::ID) && $criteria->keyContainsValue(MessageTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.MessageTableMap::ID.')'); + } + + + // Set the correct dbName + $query = MessageQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // MessageTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +MessageTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/MessageVersionTableMap.php b/core/lib/Thelia/Model/Map/MessageVersionTableMap.php new file mode 100644 index 000000000..f6587e60a --- /dev/null +++ b/core/lib/Thelia/Model/Map/MessageVersionTableMap.php @@ -0,0 +1,521 @@ + array('Id', 'Code', 'Secured', 'Ref', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'secured', 'ref', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(MessageVersionTableMap::ID, MessageVersionTableMap::CODE, MessageVersionTableMap::SECURED, MessageVersionTableMap::REF, MessageVersionTableMap::CREATED_AT, MessageVersionTableMap::UPDATED_AT, MessageVersionTableMap::VERSION, MessageVersionTableMap::VERSION_CREATED_AT, MessageVersionTableMap::VERSION_CREATED_BY, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'SECURED', 'REF', 'CREATED_AT', 'UPDATED_AT', 'VERSION', 'VERSION_CREATED_AT', 'VERSION_CREATED_BY', ), + self::TYPE_FIELDNAME => array('id', 'code', 'secured', 'ref', 'created_at', 'updated_at', 'version', 'version_created_at', 'version_created_by', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Secured' => 2, 'Ref' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'Version' => 6, 'VersionCreatedAt' => 7, 'VersionCreatedBy' => 8, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'secured' => 2, 'ref' => 3, 'createdAt' => 4, 'updatedAt' => 5, 'version' => 6, 'versionCreatedAt' => 7, 'versionCreatedBy' => 8, ), + self::TYPE_COLNAME => array(MessageVersionTableMap::ID => 0, MessageVersionTableMap::CODE => 1, MessageVersionTableMap::SECURED => 2, MessageVersionTableMap::REF => 3, MessageVersionTableMap::CREATED_AT => 4, MessageVersionTableMap::UPDATED_AT => 5, MessageVersionTableMap::VERSION => 6, MessageVersionTableMap::VERSION_CREATED_AT => 7, MessageVersionTableMap::VERSION_CREATED_BY => 8, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\MessageVersion $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion())); + } // if key === null + self::$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 \Thelia\Model\MessageVersion object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\MessageVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 6 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 6 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? MessageVersionTableMap::CLASS_DEFAULT : MessageVersionTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = MessageVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = MessageVersionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + MessageVersionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = MessageVersionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + MessageVersionTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = MessageVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = MessageVersionTableMap::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; + MessageVersionTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(MessageVersionTableMap::ID); + $criteria->addSelectColumn(MessageVersionTableMap::CODE); + $criteria->addSelectColumn(MessageVersionTableMap::SECURED); + $criteria->addSelectColumn(MessageVersionTableMap::REF); + $criteria->addSelectColumn(MessageVersionTableMap::CREATED_AT); + $criteria->addSelectColumn(MessageVersionTableMap::UPDATED_AT); + $criteria->addSelectColumn(MessageVersionTableMap::VERSION); + $criteria->addSelectColumn(MessageVersionTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(MessageVersionTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(MessageVersionTableMap::DATABASE_NAME)->getTable(MessageVersionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(MessageVersionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(MessageVersionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new MessageVersionTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\MessageVersion) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(MessageVersionTableMap::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(MessageVersionTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(MessageVersionTableMap::VERSION, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = MessageVersionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { MessageVersionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { MessageVersionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the message_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return MessageVersionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a MessageVersion or Criteria object. + * + * @param mixed $criteria Criteria or MessageVersion object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MessageVersionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from MessageVersion object + } + + + // Set the correct dbName + $query = MessageVersionQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // MessageVersionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +MessageVersionTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php new file mode 100644 index 000000000..67b7a34ef --- /dev/null +++ b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ModuleI18nTableMap::ID, ModuleI18nTableMap::LOCALE, ModuleI18nTableMap::TITLE, ModuleI18nTableMap::DESCRIPTION, ModuleI18nTableMap::CHAPO, ModuleI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ModuleI18nTableMap::ID => 0, ModuleI18nTableMap::LOCALE => 1, ModuleI18nTableMap::TITLE => 2, ModuleI18nTableMap::DESCRIPTION => 3, ModuleI18nTableMap::CHAPO => 4, ModuleI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ModuleI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\ModuleI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ModuleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ModuleI18nTableMap::CLASS_DEFAULT : ModuleI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ModuleI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ModuleI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ModuleI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ModuleI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ModuleI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ModuleI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ModuleI18nTableMap::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; + ModuleI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ModuleI18nTableMap::ID); + $criteria->addSelectColumn(ModuleI18nTableMap::LOCALE); + $criteria->addSelectColumn(ModuleI18nTableMap::TITLE); + $criteria->addSelectColumn(ModuleI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ModuleI18nTableMap::CHAPO); + $criteria->addSelectColumn(ModuleI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ModuleI18nTableMap::DATABASE_NAME)->getTable(ModuleI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ModuleI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ModuleI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ModuleI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ModuleI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ModuleI18nTableMap::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(ModuleI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ModuleI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ModuleI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ModuleI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ModuleI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the module_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ModuleI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ModuleI18n or Criteria object. + * + * @param mixed $criteria Criteria or ModuleI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ModuleI18n object + } + + + // Set the correct dbName + $query = ModuleI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ModuleI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ModuleI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php new file mode 100644 index 000000000..5370c1da1 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php @@ -0,0 +1,484 @@ + array('Id', 'Code', 'Type', 'Activate', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'type', 'activate', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ModuleTableMap::ID, ModuleTableMap::CODE, ModuleTableMap::TYPE, ModuleTableMap::ACTIVATE, ModuleTableMap::POSITION, ModuleTableMap::CREATED_AT, ModuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TYPE', 'ACTIVATE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'type', 'activate', 'position', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Type' => 2, 'Activate' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(ModuleTableMap::ID => 0, ModuleTableMap::CODE => 1, ModuleTableMap::TYPE => 2, ModuleTableMap::ACTIVATE => 3, ModuleTableMap::POSITION => 4, ModuleTableMap::CREATED_AT => 5, ModuleTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'ACTIVATE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + GroupModuleTableMap::clearInstancePool(); + ModuleI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ModuleTableMap::CLASS_DEFAULT : ModuleTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ModuleTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ModuleTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ModuleTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ModuleTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ModuleTableMap::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; + ModuleTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ModuleTableMap::ID); + $criteria->addSelectColumn(ModuleTableMap::CODE); + $criteria->addSelectColumn(ModuleTableMap::TYPE); + $criteria->addSelectColumn(ModuleTableMap::ACTIVATE); + $criteria->addSelectColumn(ModuleTableMap::POSITION); + $criteria->addSelectColumn(ModuleTableMap::CREATED_AT); + $criteria->addSelectColumn(ModuleTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ModuleTableMap::DATABASE_NAME)->getTable(ModuleTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ModuleTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ModuleTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ModuleTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Module) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ModuleTableMap::DATABASE_NAME); + $criteria->add(ModuleTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ModuleQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ModuleTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ModuleTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the module table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ModuleQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Module or Criteria object. + * + * @param mixed $criteria Criteria or Module object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ModuleTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Module object + } + + if ($criteria->containsKey(ModuleTableMap::ID) && $criteria->keyContainsValue(ModuleTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ModuleTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ModuleQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ModuleTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ModuleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderAddressTableMap.php b/core/lib/Thelia/Model/Map/OrderAddressTableMap.php new file mode 100644 index 000000000..18753e7f0 --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderAddressTableMap.php @@ -0,0 +1,529 @@ + array('Id', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'Phone', 'CountryId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'countryId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderAddressTableMap::ID, OrderAddressTableMap::CUSTOMER_TITLE_ID, OrderAddressTableMap::COMPANY, OrderAddressTableMap::FIRSTNAME, OrderAddressTableMap::LASTNAME, OrderAddressTableMap::ADDRESS1, OrderAddressTableMap::ADDRESS2, OrderAddressTableMap::ADDRESS3, OrderAddressTableMap::ZIPCODE, OrderAddressTableMap::CITY, OrderAddressTableMap::PHONE, OrderAddressTableMap::COUNTRY_ID, OrderAddressTableMap::CREATED_AT, OrderAddressTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'PHONE', 'COUNTRY_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'country_id', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::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, ), + self::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, ), + self::TYPE_COLNAME => array(OrderAddressTableMap::ID => 0, OrderAddressTableMap::CUSTOMER_TITLE_ID => 1, OrderAddressTableMap::COMPANY => 2, OrderAddressTableMap::FIRSTNAME => 3, OrderAddressTableMap::LASTNAME => 4, OrderAddressTableMap::ADDRESS1 => 5, OrderAddressTableMap::ADDRESS2 => 6, OrderAddressTableMap::ADDRESS3 => 7, OrderAddressTableMap::ZIPCODE => 8, OrderAddressTableMap::CITY => 9, OrderAddressTableMap::PHONE => 10, OrderAddressTableMap::COUNTRY_ID => 11, OrderAddressTableMap::CREATED_AT => 12, OrderAddressTableMap::UPDATED_AT => 13, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + OrderTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderAddressTableMap::CLASS_DEFAULT : OrderAddressTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderAddressTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderAddressTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderAddressTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderAddressTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderAddressTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderAddressTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderAddressTableMap::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; + OrderAddressTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(OrderAddressTableMap::ID); + $criteria->addSelectColumn(OrderAddressTableMap::CUSTOMER_TITLE_ID); + $criteria->addSelectColumn(OrderAddressTableMap::COMPANY); + $criteria->addSelectColumn(OrderAddressTableMap::FIRSTNAME); + $criteria->addSelectColumn(OrderAddressTableMap::LASTNAME); + $criteria->addSelectColumn(OrderAddressTableMap::ADDRESS1); + $criteria->addSelectColumn(OrderAddressTableMap::ADDRESS2); + $criteria->addSelectColumn(OrderAddressTableMap::ADDRESS3); + $criteria->addSelectColumn(OrderAddressTableMap::ZIPCODE); + $criteria->addSelectColumn(OrderAddressTableMap::CITY); + $criteria->addSelectColumn(OrderAddressTableMap::PHONE); + $criteria->addSelectColumn(OrderAddressTableMap::COUNTRY_ID); + $criteria->addSelectColumn(OrderAddressTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderAddressTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(OrderAddressTableMap::DATABASE_NAME)->getTable(OrderAddressTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderAddressTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderAddressTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderAddressTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderAddress) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderAddressTableMap::DATABASE_NAME); + $criteria->add(OrderAddressTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderAddressQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderAddressTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderAddressTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_address table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderAddressQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderAddress or Criteria object. + * + * @param mixed $criteria Criteria or OrderAddress object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderAddressTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderAddress object + } + + if ($criteria->containsKey(OrderAddressTableMap::ID) && $criteria->keyContainsValue(OrderAddressTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderAddressTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderAddressQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderAddressTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderAddressTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderFeatureTableMap.php b/core/lib/Thelia/Model/Map/OrderFeatureTableMap.php new file mode 100644 index 000000000..e2981b7e3 --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderFeatureTableMap.php @@ -0,0 +1,455 @@ + array('Id', 'OrderProductId', 'FeatureDesc', 'FeatureAvDesc', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'featureDesc', 'featureAvDesc', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderFeatureTableMap::ID, OrderFeatureTableMap::ORDER_PRODUCT_ID, OrderFeatureTableMap::FEATURE_DESC, OrderFeatureTableMap::FEATURE_AV_DESC, OrderFeatureTableMap::CREATED_AT, OrderFeatureTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'FEATURE_DESC', 'FEATURE_AV_DESC', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_product_id', 'feature_desc', 'feature_av_desc', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'FeatureDesc' => 2, 'FeatureAvDesc' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'featureDesc' => 2, 'featureAvDesc' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(OrderFeatureTableMap::ID => 0, OrderFeatureTableMap::ORDER_PRODUCT_ID => 1, OrderFeatureTableMap::FEATURE_DESC => 2, OrderFeatureTableMap::FEATURE_AV_DESC => 3, OrderFeatureTableMap::CREATED_AT => 4, OrderFeatureTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'FEATURE_DESC' => 2, 'FEATURE_AV_DESC' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'feature_desc' => 2, 'feature_av_desc' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderFeatureTableMap::CLASS_DEFAULT : OrderFeatureTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderFeatureTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderFeatureTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderFeatureTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderFeatureTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderFeatureTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderFeatureTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderFeatureTableMap::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; + OrderFeatureTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(OrderFeatureTableMap::ID); + $criteria->addSelectColumn(OrderFeatureTableMap::ORDER_PRODUCT_ID); + $criteria->addSelectColumn(OrderFeatureTableMap::FEATURE_DESC); + $criteria->addSelectColumn(OrderFeatureTableMap::FEATURE_AV_DESC); + $criteria->addSelectColumn(OrderFeatureTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderFeatureTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(OrderFeatureTableMap::DATABASE_NAME)->getTable(OrderFeatureTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderFeatureTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderFeatureTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderFeatureTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderFeature) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderFeatureTableMap::DATABASE_NAME); + $criteria->add(OrderFeatureTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderFeatureQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderFeatureTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderFeatureTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_feature table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderFeatureQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderFeature or Criteria object. + * + * @param mixed $criteria Criteria or OrderFeature object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderFeatureTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderFeature object + } + + if ($criteria->containsKey(OrderFeatureTableMap::ID) && $criteria->keyContainsValue(OrderFeatureTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderFeatureTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderFeatureQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderFeatureTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderFeatureTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTableMap.php new file mode 100644 index 000000000..038d12863 --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderProductTableMap.php @@ -0,0 +1,513 @@ + array('Id', 'OrderId', 'ProductRef', 'Title', 'Description', 'Chapo', 'Quantity', 'Price', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::TITLE, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::CHAPO, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::TAX, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'TITLE', 'DESCRIPTION', 'CHAPO', 'QUANTITY', 'PRICE', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::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, ), + self::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, ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::TITLE => 3, OrderProductTableMap::DESCRIPTION => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::QUANTITY => 6, OrderProductTableMap::PRICE => 7, OrderProductTableMap::TAX => 8, OrderProductTableMap::PARENT => 9, OrderProductTableMap::CREATED_AT => 10, OrderProductTableMap::UPDATED_AT => 11, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + OrderFeatureTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderProductTableMap::CLASS_DEFAULT : OrderProductTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderProductTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderProductTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderProductTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderProductTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderProductTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderProductTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderProductTableMap::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; + OrderProductTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(OrderProductTableMap::ID); + $criteria->addSelectColumn(OrderProductTableMap::ORDER_ID); + $criteria->addSelectColumn(OrderProductTableMap::PRODUCT_REF); + $criteria->addSelectColumn(OrderProductTableMap::TITLE); + $criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION); + $criteria->addSelectColumn(OrderProductTableMap::CHAPO); + $criteria->addSelectColumn(OrderProductTableMap::QUANTITY); + $criteria->addSelectColumn(OrderProductTableMap::PRICE); + $criteria->addSelectColumn(OrderProductTableMap::TAX); + $criteria->addSelectColumn(OrderProductTableMap::PARENT); + $criteria->addSelectColumn(OrderProductTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderProductTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(OrderProductTableMap::DATABASE_NAME)->getTable(OrderProductTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderProductTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderProductTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderProductTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderProduct) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderProductTableMap::DATABASE_NAME); + $criteria->add(OrderProductTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderProductQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderProductTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderProductTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_product table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderProductQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderProduct or Criteria object. + * + * @param mixed $criteria Criteria or OrderProduct object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderProductTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderProduct object + } + + if ($criteria->containsKey(OrderProductTableMap::ID) && $criteria->keyContainsValue(OrderProductTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderProductQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderProductTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderProductTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php new file mode 100644 index 000000000..5d78c474c --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(OrderStatusI18nTableMap::ID, OrderStatusI18nTableMap::LOCALE, OrderStatusI18nTableMap::TITLE, OrderStatusI18nTableMap::DESCRIPTION, OrderStatusI18nTableMap::CHAPO, OrderStatusI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(OrderStatusI18nTableMap::ID => 0, OrderStatusI18nTableMap::LOCALE => 1, OrderStatusI18nTableMap::TITLE => 2, OrderStatusI18nTableMap::DESCRIPTION => 3, OrderStatusI18nTableMap::CHAPO => 4, OrderStatusI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\OrderStatusI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\OrderStatusI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\OrderStatusI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderStatusI18nTableMap::CLASS_DEFAULT : OrderStatusI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderStatusI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderStatusI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderStatusI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderStatusI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderStatusI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderStatusI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderStatusI18nTableMap::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; + OrderStatusI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(OrderStatusI18nTableMap::ID); + $criteria->addSelectColumn(OrderStatusI18nTableMap::LOCALE); + $criteria->addSelectColumn(OrderStatusI18nTableMap::TITLE); + $criteria->addSelectColumn(OrderStatusI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(OrderStatusI18nTableMap::CHAPO); + $criteria->addSelectColumn(OrderStatusI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(OrderStatusI18nTableMap::DATABASE_NAME)->getTable(OrderStatusI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderStatusI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderStatusI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderStatusI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderStatusI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderStatusI18nTableMap::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(OrderStatusI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(OrderStatusI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = OrderStatusI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderStatusI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderStatusI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_status_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderStatusI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderStatusI18n or Criteria object. + * + * @param mixed $criteria Criteria or OrderStatusI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderStatusI18n object + } + + + // Set the correct dbName + $query = OrderStatusI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderStatusI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderStatusI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php new file mode 100644 index 000000000..eecfe5a03 --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php @@ -0,0 +1,460 @@ + array('Id', 'Code', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderStatusTableMap::ID, OrderStatusTableMap::CODE, OrderStatusTableMap::CREATED_AT, OrderStatusTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(OrderStatusTableMap::ID => 0, OrderStatusTableMap::CODE => 1, OrderStatusTableMap::CREATED_AT => 2, OrderStatusTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + OrderTableMap::clearInstancePool(); + OrderStatusI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderStatusTableMap::CLASS_DEFAULT : OrderStatusTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderStatusTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderStatusTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderStatusTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderStatusTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderStatusTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderStatusTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderStatusTableMap::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; + OrderStatusTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(OrderStatusTableMap::ID); + $criteria->addSelectColumn(OrderStatusTableMap::CODE); + $criteria->addSelectColumn(OrderStatusTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderStatusTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CODE'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(OrderStatusTableMap::DATABASE_NAME)->getTable(OrderStatusTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderStatusTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderStatusTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderStatusTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\OrderStatus) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderStatusTableMap::DATABASE_NAME); + $criteria->add(OrderStatusTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderStatusQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderStatusTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderStatusTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order_status table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderStatusQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a OrderStatus or Criteria object. + * + * @param mixed $criteria Criteria or OrderStatus object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderStatusTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from OrderStatus object + } + + if ($criteria->containsKey(OrderStatusTableMap::ID) && $criteria->keyContainsValue(OrderStatusTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderStatusTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderStatusQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderStatusTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderStatusTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderTableMap.php b/core/lib/Thelia/Model/Map/OrderTableMap.php new file mode 100644 index 000000000..91d9b29de --- /dev/null +++ b/core/lib/Thelia/Model/Map/OrderTableMap.php @@ -0,0 +1,567 @@ + array('Id', 'Ref', 'CustomerId', 'AddressInvoice', 'AddressDelivery', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'Transaction', 'DeliveryNum', 'Invoice', 'Postage', 'Payment', 'Carrier', 'StatusId', 'Lang', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'addressInvoice', 'addressDelivery', 'invoiceDate', 'currencyId', 'currencyRate', 'transaction', 'deliveryNum', 'invoice', 'postage', 'payment', 'carrier', 'statusId', 'lang', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::ADDRESS_INVOICE, OrderTableMap::ADDRESS_DELIVERY, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION, OrderTableMap::DELIVERY_NUM, OrderTableMap::INVOICE, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT, OrderTableMap::CARRIER, OrderTableMap::STATUS_ID, OrderTableMap::LANG, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, ), + self::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', ), + self::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', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::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, ), + self::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, ), + self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::ADDRESS_INVOICE => 3, OrderTableMap::ADDRESS_DELIVERY => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION => 8, OrderTableMap::DELIVERY_NUM => 9, OrderTableMap::INVOICE => 10, OrderTableMap::POSTAGE => 11, OrderTableMap::PAYMENT => 12, OrderTableMap::CARRIER => 13, OrderTableMap::STATUS_ID => 14, OrderTableMap::LANG => 15, OrderTableMap::CREATED_AT => 16, OrderTableMap::UPDATED_AT => 17, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + OrderProductTableMap::clearInstancePool(); + CouponOrderTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? OrderTableMap::CLASS_DEFAULT : OrderTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = OrderTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = OrderTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + OrderTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = OrderTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + OrderTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = OrderTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = OrderTableMap::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; + OrderTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(OrderTableMap::ID); + $criteria->addSelectColumn(OrderTableMap::REF); + $criteria->addSelectColumn(OrderTableMap::CUSTOMER_ID); + $criteria->addSelectColumn(OrderTableMap::ADDRESS_INVOICE); + $criteria->addSelectColumn(OrderTableMap::ADDRESS_DELIVERY); + $criteria->addSelectColumn(OrderTableMap::INVOICE_DATE); + $criteria->addSelectColumn(OrderTableMap::CURRENCY_ID); + $criteria->addSelectColumn(OrderTableMap::CURRENCY_RATE); + $criteria->addSelectColumn(OrderTableMap::TRANSACTION); + $criteria->addSelectColumn(OrderTableMap::DELIVERY_NUM); + $criteria->addSelectColumn(OrderTableMap::INVOICE); + $criteria->addSelectColumn(OrderTableMap::POSTAGE); + $criteria->addSelectColumn(OrderTableMap::PAYMENT); + $criteria->addSelectColumn(OrderTableMap::CARRIER); + $criteria->addSelectColumn(OrderTableMap::STATUS_ID); + $criteria->addSelectColumn(OrderTableMap::LANG); + $criteria->addSelectColumn(OrderTableMap::CREATED_AT); + $criteria->addSelectColumn(OrderTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(OrderTableMap::DATABASE_NAME)->getTable(OrderTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(OrderTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new OrderTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Order) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(OrderTableMap::DATABASE_NAME); + $criteria->add(OrderTableMap::ID, (array) $values, Criteria::IN); + } + + $query = OrderQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { OrderTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { OrderTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the order table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return OrderQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Order or Criteria object. + * + * @param mixed $criteria Criteria or Order object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(OrderTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Order object + } + + if ($criteria->containsKey(OrderTableMap::ID) && $criteria->keyContainsValue(OrderTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderTableMap::ID.')'); + } + + + // Set the correct dbName + $query = OrderQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // OrderTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +OrderTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php new file mode 100644 index 000000000..6a8361f27 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProductCategoryTableMap.php @@ -0,0 +1,496 @@ + array('ProductId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('productId', 'categoryId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID, ProductCategoryTableMap::CATEGORY_ID, ProductCategoryTableMap::CREATED_AT, ProductCategoryTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('PRODUCT_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('product_id', 'category_id', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('ProductId' => 0, 'CategoryId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('productId' => 0, 'categoryId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(ProductCategoryTableMap::PRODUCT_ID => 0, ProductCategoryTableMap::CATEGORY_ID => 1, ProductCategoryTableMap::CREATED_AT => 2, ProductCategoryTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('product_id' => 0, 'category_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ProductCategory $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getProductId(), (string) $obj->getCategoryId())); + } // if key === null + self::$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 \Thelia\Model\ProductCategory object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProductCategory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('CategoryId', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProductCategoryTableMap::CLASS_DEFAULT : ProductCategoryTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProductCategoryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProductCategoryTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProductCategoryTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProductCategoryTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProductCategoryTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProductCategoryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProductCategoryTableMap::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; + ProductCategoryTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ProductCategoryTableMap::PRODUCT_ID); + $criteria->addSelectColumn(ProductCategoryTableMap::CATEGORY_ID); + $criteria->addSelectColumn(ProductCategoryTableMap::CREATED_AT); + $criteria->addSelectColumn(ProductCategoryTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ProductCategoryTableMap::DATABASE_NAME)->getTable(ProductCategoryTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductCategoryTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProductCategoryTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProductCategoryTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ProductCategory) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProductCategoryTableMap::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(ProductCategoryTableMap::PRODUCT_ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ProductCategoryTableMap::CATEGORY_ID, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ProductCategoryQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProductCategoryTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProductCategoryTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the product_category table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProductCategoryQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ProductCategory or Criteria object. + * + * @param mixed $criteria Criteria or ProductCategory object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductCategoryTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ProductCategory object + } + + + // Set the correct dbName + $query = ProductCategoryQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProductCategoryTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProductCategoryTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php new file mode 100644 index 000000000..8da33f15d --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ProductI18nTableMap::ID, ProductI18nTableMap::LOCALE, ProductI18nTableMap::TITLE, ProductI18nTableMap::DESCRIPTION, ProductI18nTableMap::CHAPO, ProductI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ProductI18nTableMap::ID => 0, ProductI18nTableMap::LOCALE => 1, ProductI18nTableMap::TITLE => 2, ProductI18nTableMap::DESCRIPTION => 3, ProductI18nTableMap::CHAPO => 4, ProductI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ProductI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\ProductI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProductI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProductI18nTableMap::CLASS_DEFAULT : ProductI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProductI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProductI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProductI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProductI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProductI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProductI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProductI18nTableMap::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; + ProductI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ProductI18nTableMap::ID); + $criteria->addSelectColumn(ProductI18nTableMap::LOCALE); + $criteria->addSelectColumn(ProductI18nTableMap::TITLE); + $criteria->addSelectColumn(ProductI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ProductI18nTableMap::CHAPO); + $criteria->addSelectColumn(ProductI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ProductI18nTableMap::DATABASE_NAME)->getTable(ProductI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProductI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProductI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ProductI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProductI18nTableMap::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(ProductI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ProductI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ProductI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProductI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProductI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the product_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProductI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ProductI18n or Criteria object. + * + * @param mixed $criteria Criteria or ProductI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ProductI18n object + } + + + // Set the correct dbName + $query = ProductI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProductI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProductI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php new file mode 100644 index 000000000..b009a97af --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -0,0 +1,586 @@ + array('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Quantity', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(ProductTableMap::ID, ProductTableMap::TAX_RULE_ID, ProductTableMap::REF, ProductTableMap::PRICE, ProductTableMap::PRICE2, ProductTableMap::ECOTAX, ProductTableMap::NEWNESS, ProductTableMap::PROMO, ProductTableMap::QUANTITY, ProductTableMap::VISIBLE, ProductTableMap::WEIGHT, ProductTableMap::POSITION, ProductTableMap::CREATED_AT, ProductTableMap::UPDATED_AT, ProductTableMap::VERSION, ProductTableMap::VERSION_CREATED_AT, ProductTableMap::VERSION_CREATED_BY, ), + self::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', ), + self::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', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::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, ), + self::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, ), + self::TYPE_COLNAME => array(ProductTableMap::ID => 0, ProductTableMap::TAX_RULE_ID => 1, ProductTableMap::REF => 2, ProductTableMap::PRICE => 3, ProductTableMap::PRICE2 => 4, ProductTableMap::ECOTAX => 5, ProductTableMap::NEWNESS => 6, ProductTableMap::PROMO => 7, ProductTableMap::QUANTITY => 8, ProductTableMap::VISIBLE => 9, ProductTableMap::WEIGHT => 10, ProductTableMap::POSITION => 11, ProductTableMap::CREATED_AT => 12, ProductTableMap::UPDATED_AT => 13, ProductTableMap::VERSION => 14, ProductTableMap::VERSION_CREATED_AT => 15, ProductTableMap::VERSION_CREATED_BY => 16, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'ProductCategories'); + $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', 'AccessoriesRelatedByProductId'); + $this->addRelation('AccessoryRelatedByAccessory', '\\Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessoriesRelatedByAccessory'); + $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', 'Categories'); + $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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + 'versionable' => array('version_column' => 'version', 'version_table' => '', 'log_created_at' => 'true', 'log_created_by' => 'true', 'log_comment' => 'false', 'version_created_at_column' => 'version_created_at', 'version_created_by_column' => 'version_created_by', 'version_comment_column' => 'version_comment', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ProductCategoryTableMap::clearInstancePool(); + FeatureProdTableMap::clearInstancePool(); + StockTableMap::clearInstancePool(); + ContentAssocTableMap::clearInstancePool(); + ImageTableMap::clearInstancePool(); + DocumentTableMap::clearInstancePool(); + AccessoryTableMap::clearInstancePool(); + RewritingTableMap::clearInstancePool(); + ProductI18nTableMap::clearInstancePool(); + ProductVersionTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProductTableMap::CLASS_DEFAULT : ProductTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProductTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProductTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProductTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProductTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProductTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProductTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProductTableMap::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; + ProductTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ProductTableMap::ID); + $criteria->addSelectColumn(ProductTableMap::TAX_RULE_ID); + $criteria->addSelectColumn(ProductTableMap::REF); + $criteria->addSelectColumn(ProductTableMap::PRICE); + $criteria->addSelectColumn(ProductTableMap::PRICE2); + $criteria->addSelectColumn(ProductTableMap::ECOTAX); + $criteria->addSelectColumn(ProductTableMap::NEWNESS); + $criteria->addSelectColumn(ProductTableMap::PROMO); + $criteria->addSelectColumn(ProductTableMap::QUANTITY); + $criteria->addSelectColumn(ProductTableMap::VISIBLE); + $criteria->addSelectColumn(ProductTableMap::WEIGHT); + $criteria->addSelectColumn(ProductTableMap::POSITION); + $criteria->addSelectColumn(ProductTableMap::CREATED_AT); + $criteria->addSelectColumn(ProductTableMap::UPDATED_AT); + $criteria->addSelectColumn(ProductTableMap::VERSION); + $criteria->addSelectColumn(ProductTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(ProductTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ProductTableMap::DATABASE_NAME)->getTable(ProductTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProductTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProductTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Product) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProductTableMap::DATABASE_NAME); + $criteria->add(ProductTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ProductQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProductTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProductTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the product table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProductQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Product or Criteria object. + * + * @param mixed $criteria Criteria or Product object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Product object + } + + if ($criteria->containsKey(ProductTableMap::ID) && $criteria->keyContainsValue(ProductTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ProductQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProductTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProductTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProductVersionTableMap.php b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php new file mode 100644 index 000000000..fb285a6db --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProductVersionTableMap.php @@ -0,0 +1,585 @@ + array('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Quantity', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), + self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', 'visible', 'weight', 'position', 'createdAt', 'updatedAt', 'version', 'versionCreatedAt', 'versionCreatedBy', ), + self::TYPE_COLNAME => array(ProductVersionTableMap::ID, ProductVersionTableMap::TAX_RULE_ID, ProductVersionTableMap::REF, ProductVersionTableMap::PRICE, ProductVersionTableMap::PRICE2, ProductVersionTableMap::ECOTAX, ProductVersionTableMap::NEWNESS, ProductVersionTableMap::PROMO, ProductVersionTableMap::QUANTITY, ProductVersionTableMap::VISIBLE, ProductVersionTableMap::WEIGHT, ProductVersionTableMap::POSITION, ProductVersionTableMap::CREATED_AT, ProductVersionTableMap::UPDATED_AT, ProductVersionTableMap::VERSION, ProductVersionTableMap::VERSION_CREATED_AT, ProductVersionTableMap::VERSION_CREATED_BY, ), + self::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', ), + self::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', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::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, ), + self::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, ), + self::TYPE_COLNAME => array(ProductVersionTableMap::ID => 0, ProductVersionTableMap::TAX_RULE_ID => 1, ProductVersionTableMap::REF => 2, ProductVersionTableMap::PRICE => 3, ProductVersionTableMap::PRICE2 => 4, ProductVersionTableMap::ECOTAX => 5, ProductVersionTableMap::NEWNESS => 6, ProductVersionTableMap::PROMO => 7, ProductVersionTableMap::QUANTITY => 8, ProductVersionTableMap::VISIBLE => 9, ProductVersionTableMap::WEIGHT => 10, ProductVersionTableMap::POSITION => 11, ProductVersionTableMap::CREATED_AT => 12, ProductVersionTableMap::UPDATED_AT => 13, ProductVersionTableMap::VERSION => 14, ProductVersionTableMap::VERSION_CREATED_AT => 15, ProductVersionTableMap::VERSION_CREATED_BY => 16, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ProductVersion $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getVersion())); + } // if key === null + self::$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 \Thelia\Model\ProductVersion object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProductVersion object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 14 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 14 + $offset : static::translateFieldName('Version', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProductVersionTableMap::CLASS_DEFAULT : ProductVersionTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProductVersionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProductVersionTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProductVersionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProductVersionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProductVersionTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProductVersionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProductVersionTableMap::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; + ProductVersionTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ProductVersionTableMap::ID); + $criteria->addSelectColumn(ProductVersionTableMap::TAX_RULE_ID); + $criteria->addSelectColumn(ProductVersionTableMap::REF); + $criteria->addSelectColumn(ProductVersionTableMap::PRICE); + $criteria->addSelectColumn(ProductVersionTableMap::PRICE2); + $criteria->addSelectColumn(ProductVersionTableMap::ECOTAX); + $criteria->addSelectColumn(ProductVersionTableMap::NEWNESS); + $criteria->addSelectColumn(ProductVersionTableMap::PROMO); + $criteria->addSelectColumn(ProductVersionTableMap::QUANTITY); + $criteria->addSelectColumn(ProductVersionTableMap::VISIBLE); + $criteria->addSelectColumn(ProductVersionTableMap::WEIGHT); + $criteria->addSelectColumn(ProductVersionTableMap::POSITION); + $criteria->addSelectColumn(ProductVersionTableMap::CREATED_AT); + $criteria->addSelectColumn(ProductVersionTableMap::UPDATED_AT); + $criteria->addSelectColumn(ProductVersionTableMap::VERSION); + $criteria->addSelectColumn(ProductVersionTableMap::VERSION_CREATED_AT); + $criteria->addSelectColumn(ProductVersionTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ProductVersionTableMap::DATABASE_NAME)->getTable(ProductVersionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProductVersionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProductVersionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProductVersionTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ProductVersion) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProductVersionTableMap::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(ProductVersionTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ProductVersionTableMap::VERSION, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ProductVersionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProductVersionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProductVersionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the product_version table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProductVersionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ProductVersion or Criteria object. + * + * @param mixed $criteria Criteria or ProductVersion object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProductVersionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ProductVersion object + } + + + // Set the correct dbName + $query = ProductVersionQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProductVersionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProductVersionTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php new file mode 100644 index 000000000..8a8ce501a --- /dev/null +++ b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ResourceI18nTableMap::ID, ResourceI18nTableMap::LOCALE, ResourceI18nTableMap::TITLE, ResourceI18nTableMap::DESCRIPTION, ResourceI18nTableMap::CHAPO, ResourceI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ResourceI18nTableMap::ID => 0, ResourceI18nTableMap::LOCALE => 1, ResourceI18nTableMap::TITLE => 2, ResourceI18nTableMap::DESCRIPTION => 3, ResourceI18nTableMap::CHAPO => 4, ResourceI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $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); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ResourceI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\ResourceI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ResourceI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ResourceI18nTableMap::CLASS_DEFAULT : ResourceI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ResourceI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ResourceI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ResourceI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ResourceI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ResourceI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ResourceI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ResourceI18nTableMap::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; + ResourceI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ResourceI18nTableMap::ID); + $criteria->addSelectColumn(ResourceI18nTableMap::LOCALE); + $criteria->addSelectColumn(ResourceI18nTableMap::TITLE); + $criteria->addSelectColumn(ResourceI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ResourceI18nTableMap::CHAPO); + $criteria->addSelectColumn(ResourceI18nTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ResourceI18nTableMap::DATABASE_NAME)->getTable(ResourceI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ResourceI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ResourceI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ResourceI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ResourceI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ResourceI18nTableMap::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(ResourceI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ResourceI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ResourceI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ResourceI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ResourceI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the resource_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ResourceI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ResourceI18n or Criteria object. + * + * @param mixed $criteria Criteria or ResourceI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ResourceI18n object + } + + + // Set the correct dbName + $query = ResourceI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ResourceI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ResourceI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ResourceTableMap.php b/core/lib/Thelia/Model/Map/ResourceTableMap.php new file mode 100644 index 000000000..e56960892 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ResourceTableMap.php @@ -0,0 +1,461 @@ + array('Id', 'Code', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ResourceTableMap::ID, ResourceTableMap::CODE, ResourceTableMap::CREATED_AT, ResourceTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(ResourceTableMap::ID => 0, ResourceTableMap::CODE => 1, ResourceTableMap::CREATED_AT => 2, ResourceTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + GroupResourceTableMap::clearInstancePool(); + ResourceI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ResourceTableMap::CLASS_DEFAULT : ResourceTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ResourceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ResourceTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ResourceTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ResourceTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ResourceTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ResourceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ResourceTableMap::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; + ResourceTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(ResourceTableMap::ID); + $criteria->addSelectColumn(ResourceTableMap::CODE); + $criteria->addSelectColumn(ResourceTableMap::CREATED_AT); + $criteria->addSelectColumn(ResourceTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CODE'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(ResourceTableMap::DATABASE_NAME)->getTable(ResourceTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ResourceTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ResourceTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ResourceTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Resource) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ResourceTableMap::DATABASE_NAME); + $criteria->add(ResourceTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ResourceQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ResourceTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ResourceTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the resource table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ResourceQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Resource or Criteria object. + * + * @param mixed $criteria Criteria or Resource object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ResourceTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Resource object + } + + if ($criteria->containsKey(ResourceTableMap::ID) && $criteria->keyContainsValue(ResourceTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ResourceTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ResourceQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ResourceTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ResourceTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/RewritingTableMap.php b/core/lib/Thelia/Model/Map/RewritingTableMap.php new file mode 100644 index 000000000..afce3e3c7 --- /dev/null +++ b/core/lib/Thelia/Model/Map/RewritingTableMap.php @@ -0,0 +1,470 @@ + array('Id', 'Url', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'url', 'productId', 'categoryId', 'folderId', 'contentId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(RewritingTableMap::ID, RewritingTableMap::URL, RewritingTableMap::PRODUCT_ID, RewritingTableMap::CATEGORY_ID, RewritingTableMap::FOLDER_ID, RewritingTableMap::CONTENT_ID, RewritingTableMap::CREATED_AT, RewritingTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'URL', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'url', 'product_id', 'category_id', 'folder_id', 'content_id', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Url' => 1, 'ProductId' => 2, 'CategoryId' => 3, 'FolderId' => 4, 'ContentId' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'url' => 1, 'productId' => 2, 'categoryId' => 3, 'folderId' => 4, 'contentId' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(RewritingTableMap::ID => 0, RewritingTableMap::URL => 1, RewritingTableMap::PRODUCT_ID => 2, RewritingTableMap::CATEGORY_ID => 3, RewritingTableMap::FOLDER_ID => 4, RewritingTableMap::CONTENT_ID => 5, RewritingTableMap::CREATED_AT => 6, RewritingTableMap::UPDATED_AT => 7, ), + self::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, ), + self::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, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? RewritingTableMap::CLASS_DEFAULT : RewritingTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = RewritingTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = RewritingTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + RewritingTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = RewritingTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + RewritingTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = RewritingTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = RewritingTableMap::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; + RewritingTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(RewritingTableMap::ID); + $criteria->addSelectColumn(RewritingTableMap::URL); + $criteria->addSelectColumn(RewritingTableMap::PRODUCT_ID); + $criteria->addSelectColumn(RewritingTableMap::CATEGORY_ID); + $criteria->addSelectColumn(RewritingTableMap::FOLDER_ID); + $criteria->addSelectColumn(RewritingTableMap::CONTENT_ID); + $criteria->addSelectColumn(RewritingTableMap::CREATED_AT); + $criteria->addSelectColumn(RewritingTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(RewritingTableMap::DATABASE_NAME)->getTable(RewritingTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(RewritingTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(RewritingTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new RewritingTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Rewriting) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(RewritingTableMap::DATABASE_NAME); + $criteria->add(RewritingTableMap::ID, (array) $values, Criteria::IN); + } + + $query = RewritingQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { RewritingTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { RewritingTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the rewriting table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return RewritingQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Rewriting or Criteria object. + * + * @param mixed $criteria Criteria or Rewriting object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(RewritingTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Rewriting object + } + + + // Set the correct dbName + $query = RewritingQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // RewritingTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +RewritingTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/StockTableMap.php b/core/lib/Thelia/Model/Map/StockTableMap.php new file mode 100644 index 000000000..470f7a0a8 --- /dev/null +++ b/core/lib/Thelia/Model/Map/StockTableMap.php @@ -0,0 +1,464 @@ + array('Id', 'CombinationId', 'ProductId', 'Increase', 'Value', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'combinationId', 'productId', 'increase', 'value', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(StockTableMap::ID, StockTableMap::COMBINATION_ID, StockTableMap::PRODUCT_ID, StockTableMap::INCREASE, StockTableMap::VALUE, StockTableMap::CREATED_AT, StockTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'COMBINATION_ID', 'PRODUCT_ID', 'INCREASE', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'combination_id', 'product_id', 'increase', 'value', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'CombinationId' => 1, 'ProductId' => 2, 'Increase' => 3, 'Value' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'combinationId' => 1, 'productId' => 2, 'increase' => 3, 'value' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(StockTableMap::ID => 0, StockTableMap::COMBINATION_ID => 1, StockTableMap::PRODUCT_ID => 2, StockTableMap::INCREASE => 3, StockTableMap::VALUE => 4, StockTableMap::CREATED_AT => 5, StockTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'COMBINATION_ID' => 1, 'PRODUCT_ID' => 2, 'INCREASE' => 3, 'VALUE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'combination_id' => 1, 'product_id' => 2, 'increase' => 3, 'value' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? StockTableMap::CLASS_DEFAULT : StockTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = StockTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = StockTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + StockTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = StockTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + StockTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = StockTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = StockTableMap::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; + StockTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(StockTableMap::ID); + $criteria->addSelectColumn(StockTableMap::COMBINATION_ID); + $criteria->addSelectColumn(StockTableMap::PRODUCT_ID); + $criteria->addSelectColumn(StockTableMap::INCREASE); + $criteria->addSelectColumn(StockTableMap::VALUE); + $criteria->addSelectColumn(StockTableMap::CREATED_AT); + $criteria->addSelectColumn(StockTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(StockTableMap::DATABASE_NAME)->getTable(StockTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(StockTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(StockTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new StockTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Stock) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(StockTableMap::DATABASE_NAME); + $criteria->add(StockTableMap::ID, (array) $values, Criteria::IN); + } + + $query = StockQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { StockTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { StockTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the stock table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return StockQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Stock or Criteria object. + * + * @param mixed $criteria Criteria or Stock object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(StockTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Stock object + } + + if ($criteria->containsKey(StockTableMap::ID) && $criteria->keyContainsValue(StockTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.StockTableMap::ID.')'); + } + + + // Set the correct dbName + $query = StockQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // StockTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +StockTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php new file mode 100644 index 000000000..2c4c92f4f --- /dev/null +++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php @@ -0,0 +1,481 @@ + array('Id', 'Locale', 'Title', 'Description', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', ), + self::TYPE_COLNAME => array(TaxI18nTableMap::ID, TaxI18nTableMap::LOCALE, TaxI18nTableMap::TITLE, TaxI18nTableMap::DESCRIPTION, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, ), + self::TYPE_COLNAME => array(TaxI18nTableMap::ID => 0, TaxI18nTableMap::LOCALE => 1, TaxI18nTableMap::TITLE => 2, TaxI18nTableMap::DESCRIPTION => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\TaxI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\TaxI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\TaxI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? TaxI18nTableMap::CLASS_DEFAULT : TaxI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = TaxI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = TaxI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + TaxI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = TaxI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + TaxI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = TaxI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = TaxI18nTableMap::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; + TaxI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(TaxI18nTableMap::ID); + $criteria->addSelectColumn(TaxI18nTableMap::LOCALE); + $criteria->addSelectColumn(TaxI18nTableMap::TITLE); + $criteria->addSelectColumn(TaxI18nTableMap::DESCRIPTION); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(TaxI18nTableMap::DATABASE_NAME)->getTable(TaxI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(TaxI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new TaxI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\TaxI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(TaxI18nTableMap::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(TaxI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(TaxI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = TaxI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { TaxI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { TaxI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the tax_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return TaxI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a TaxI18n or Criteria object. + * + * @param mixed $criteria Criteria or TaxI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from TaxI18n object + } + + + // Set the correct dbName + $query = TaxI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // TaxI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +TaxI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php new file mode 100644 index 000000000..42b4e6f59 --- /dev/null +++ b/core/lib/Thelia/Model/Map/TaxRuleCountryTableMap.php @@ -0,0 +1,461 @@ + array('Id', 'TaxRuleId', 'CountryId', 'TaxId', 'None', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'taxRuleId', 'countryId', 'taxId', 'none', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(TaxRuleCountryTableMap::ID, TaxRuleCountryTableMap::TAX_RULE_ID, TaxRuleCountryTableMap::COUNTRY_ID, TaxRuleCountryTableMap::TAX_ID, TaxRuleCountryTableMap::NONE, TaxRuleCountryTableMap::CREATED_AT, TaxRuleCountryTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'TAX_RULE_ID', 'COUNTRY_ID', 'TAX_ID', 'NONE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'tax_rule_id', 'country_id', 'tax_id', 'none', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'TaxRuleId' => 1, 'CountryId' => 2, 'TaxId' => 3, 'None' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'taxRuleId' => 1, 'countryId' => 2, 'taxId' => 3, 'none' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(TaxRuleCountryTableMap::ID => 0, TaxRuleCountryTableMap::TAX_RULE_ID => 1, TaxRuleCountryTableMap::COUNTRY_ID => 2, TaxRuleCountryTableMap::TAX_ID => 3, TaxRuleCountryTableMap::NONE => 4, TaxRuleCountryTableMap::CREATED_AT => 5, TaxRuleCountryTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'TAX_RULE_ID' => 1, 'COUNTRY_ID' => 2, 'TAX_ID' => 3, 'NONE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'tax_rule_id' => 1, 'country_id' => 2, 'tax_id' => 3, 'none' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? TaxRuleCountryTableMap::CLASS_DEFAULT : TaxRuleCountryTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = TaxRuleCountryTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = TaxRuleCountryTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + TaxRuleCountryTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = TaxRuleCountryTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + TaxRuleCountryTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = TaxRuleCountryTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = TaxRuleCountryTableMap::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; + TaxRuleCountryTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(TaxRuleCountryTableMap::ID); + $criteria->addSelectColumn(TaxRuleCountryTableMap::TAX_RULE_ID); + $criteria->addSelectColumn(TaxRuleCountryTableMap::COUNTRY_ID); + $criteria->addSelectColumn(TaxRuleCountryTableMap::TAX_ID); + $criteria->addSelectColumn(TaxRuleCountryTableMap::NONE); + $criteria->addSelectColumn(TaxRuleCountryTableMap::CREATED_AT); + $criteria->addSelectColumn(TaxRuleCountryTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(TaxRuleCountryTableMap::DATABASE_NAME)->getTable(TaxRuleCountryTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxRuleCountryTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(TaxRuleCountryTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new TaxRuleCountryTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\TaxRuleCountry) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(TaxRuleCountryTableMap::DATABASE_NAME); + $criteria->add(TaxRuleCountryTableMap::ID, (array) $values, Criteria::IN); + } + + $query = TaxRuleCountryQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { TaxRuleCountryTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { TaxRuleCountryTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the tax_rule_country table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return TaxRuleCountryQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a TaxRuleCountry or Criteria object. + * + * @param mixed $criteria Criteria or TaxRuleCountry object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleCountryTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from TaxRuleCountry object + } + + + // Set the correct dbName + $query = TaxRuleCountryQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // TaxRuleCountryTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +TaxRuleCountryTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php new file mode 100644 index 000000000..689f30728 --- /dev/null +++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php @@ -0,0 +1,465 @@ + array('Id', 'Locale', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', ), + self::TYPE_COLNAME => array(TaxRuleI18nTableMap::ID, TaxRuleI18nTableMap::LOCALE, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', ), + self::TYPE_FIELDNAME => array('id', 'locale', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, ), + self::TYPE_COLNAME => array(TaxRuleI18nTableMap::ID => 0, TaxRuleI18nTableMap::LOCALE => 1, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, ), + self::TYPE_NUM => array(0, 1, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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_EN'); + } // 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() + + /** + * 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 you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\TaxRuleI18n $obj A \Thelia\Model\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 (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$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 \Thelia\Model\TaxRuleI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\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])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\TaxRuleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? TaxRuleI18nTableMap::CLASS_DEFAULT : TaxRuleI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = TaxRuleI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = TaxRuleI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + TaxRuleI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = TaxRuleI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + TaxRuleI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = TaxRuleI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = TaxRuleI18nTableMap::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; + TaxRuleI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(TaxRuleI18nTableMap::ID); + $criteria->addSelectColumn(TaxRuleI18nTableMap::LOCALE); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(TaxRuleI18nTableMap::DATABASE_NAME)->getTable(TaxRuleI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxRuleI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(TaxRuleI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new TaxRuleI18nTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\TaxRuleI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(TaxRuleI18nTableMap::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(TaxRuleI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(TaxRuleI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = TaxRuleI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { TaxRuleI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { TaxRuleI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the tax_rule_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return TaxRuleI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a TaxRuleI18n or Criteria object. + * + * @param mixed $criteria Criteria or TaxRuleI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from TaxRuleI18n object + } + + + // Set the correct dbName + $query = TaxRuleI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // TaxRuleI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +TaxRuleI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php new file mode 100644 index 000000000..9b862de99 --- /dev/null +++ b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php @@ -0,0 +1,478 @@ + array('Id', 'Code', 'Title', 'Description', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'title', 'description', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::CODE, TaxRuleTableMap::TITLE, TaxRuleTableMap::DESCRIPTION, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'TITLE', 'DESCRIPTION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'title', 'description', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'Title' => 2, 'Description' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'title' => 2, 'description' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::CODE => 1, TaxRuleTableMap::TITLE => 2, TaxRuleTableMap::DESCRIPTION => 3, TaxRuleTableMap::CREATED_AT => 4, TaxRuleTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'title' => 2, 'description' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'TaxRuleCountries'); + $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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => '', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + ProductTableMap::clearInstancePool(); + TaxRuleCountryTableMap::clearInstancePool(); + TaxRuleI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? TaxRuleTableMap::CLASS_DEFAULT : TaxRuleTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = TaxRuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = TaxRuleTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + TaxRuleTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = TaxRuleTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + TaxRuleTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = TaxRuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = TaxRuleTableMap::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; + TaxRuleTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(TaxRuleTableMap::ID); + $criteria->addSelectColumn(TaxRuleTableMap::CODE); + $criteria->addSelectColumn(TaxRuleTableMap::TITLE); + $criteria->addSelectColumn(TaxRuleTableMap::DESCRIPTION); + $criteria->addSelectColumn(TaxRuleTableMap::CREATED_AT); + $criteria->addSelectColumn(TaxRuleTableMap::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 TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(TaxRuleTableMap::DATABASE_NAME)->getTable(TaxRuleTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxRuleTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(TaxRuleTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new TaxRuleTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\TaxRule) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(TaxRuleTableMap::DATABASE_NAME); + $criteria->add(TaxRuleTableMap::ID, (array) $values, Criteria::IN); + } + + $query = TaxRuleQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { TaxRuleTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { TaxRuleTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the tax_rule table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return TaxRuleQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a TaxRule or Criteria object. + * + * @param mixed $criteria Criteria or TaxRule object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxRuleTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from TaxRule object + } + + if ($criteria->containsKey(TaxRuleTableMap::ID) && $criteria->keyContainsValue(TaxRuleTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxRuleTableMap::ID.')'); + } + + + // Set the correct dbName + $query = TaxRuleQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // TaxRuleTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +TaxRuleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/TaxTableMap.php b/core/lib/Thelia/Model/Map/TaxTableMap.php new file mode 100644 index 000000000..b941e7b52 --- /dev/null +++ b/core/lib/Thelia/Model/Map/TaxTableMap.php @@ -0,0 +1,460 @@ + array('Id', 'Rate', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'rate', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::RATE, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'RATE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'rate', 'created_at', 'updated_at', ), + self::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. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Rate' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'rate' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::RATE => 1, TaxTableMap::CREATED_AT => 2, TaxTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'RATE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'rate' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->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); + } // 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', 'TaxRuleCountries'); + $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', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * 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 ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + TaxRuleCountryTableMap::clearInstancePool(); + TaxI18nTableMap::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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * 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 resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? TaxTableMap::CLASS_DEFAULT : TaxTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @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, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = TaxTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = TaxTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + TaxTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = TaxTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + TaxTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = TaxTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = TaxTableMap::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; + TaxTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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(TaxTableMap::ID); + $criteria->addSelectColumn(TaxTableMap::RATE); + $criteria->addSelectColumn(TaxTableMap::CREATED_AT); + $criteria->addSelectColumn(TaxTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.RATE'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(TaxTableMap::DATABASE_NAME)->getTable(TaxTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(TaxTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(TaxTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new TaxTableMap()); + } + } + + /** + * 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 ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Tax) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(TaxTableMap::DATABASE_NAME); + $criteria->add(TaxTableMap::ID, (array) $values, Criteria::IN); + } + + $query = TaxQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { TaxTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { TaxTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the tax table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return TaxQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Tax or Criteria object. + * + * @param mixed $criteria Criteria or Tax object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(TaxTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Tax object + } + + if ($criteria->containsKey(TaxTableMap::ID) && $criteria->keyContainsValue(TaxTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxTableMap::ID.')'); + } + + + // Set the correct dbName + $query = TaxQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // TaxTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +TaxTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Message.php b/core/lib/Thelia/Model/Message.php old mode 100755 new mode 100644 index 9e529b92b..777c9eaaf --- a/core/lib/Thelia/Model/Message.php +++ b/core/lib/Thelia/Model/Message.php @@ -2,20 +2,8 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseMessage; +use Thelia\Model\Base\Message as BaseMessage; +class Message extends BaseMessage { -/** - * Skeleton subclass for representing a row from the 'message' 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 Message extends BaseMessage -{ } diff --git a/core/lib/Thelia/Model/MessageI18n.php b/core/lib/Thelia/Model/MessageI18n.php old mode 100755 new mode 100644 index 4a53e358e..07766d122 --- a/core/lib/Thelia/Model/MessageI18n.php +++ b/core/lib/Thelia/Model/MessageI18n.php @@ -2,20 +2,8 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseMessageI18n; +use Thelia\Model\Base\MessageI18n as BaseMessageI18n; +class MessageI18n extends BaseMessageI18n { -/** - * Skeleton subclass for representing a row from the 'message_i18n' 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 MessageI18n extends BaseMessageI18n -{ } diff --git a/core/lib/Thelia/Model/MessageI18nPeer.php b/core/lib/Thelia/Model/MessageI18nPeer.php deleted file mode 100755 index df52f42eb..000000000 --- a/core/lib/Thelia/Model/MessageI18nPeer.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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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 @@ - + diff --git a/templates/smarty-sample/connexion.html b/templates/smarty-sample/connexion.html new file mode 100644 index 000000000..44b13386e --- /dev/null +++ b/templates/smarty-sample/connexion.html @@ -0,0 +1,138 @@ +{include file="includes/header.html"} + +{form name="thelia.customer.creation"} + + + {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} + {/form_error} + +
+ {/form_field} + + {form_field form=$form.lastname} + {form_error form=$form.lastname} + {$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.city} + {form_error form=$form.city} + {$message} + {/form_error} + +
+ {/form_field} + + {form_field form=$form.country} + {form_error form=$form.country} + {$message} + {/form_error} + + + +
+ {/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} + {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} + +{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 d24efa89c..5a73519b0 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -7,44 +7,32 @@ 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} - {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}
jQuery data:
-

Category loop example

-
    - {loop type="category" name="catloop1"} -
  • {$LOOP_COUNT}/{$LOOP_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} -
+

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

@@ -52,7 +40,7 @@ An image from asset directory : Hey ! Loop catloop2 is not empty:
    {loop type="category" name="catloop2" parent="12"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • +
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • {/loop}
{/ifloop} @@ -69,7 +57,7 @@ An image from asset directory : Loop catloop3 is not empty:
    {loop type="category" name="catloop3" parent="0"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • +
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • {/loop}
{/ifloop} @@ -81,9 +69,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} +
@@ -93,32 +79,27 @@ An image from asset directory : {/for}
-
-

Loops also work with #

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

Some pagination

PAGE 1

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

PAGE 2

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

PAGE 1000

    {loop type="category" name="catloopwithpagination1000" limit="2" page="1000"} -
  • {$LOOP_COUNT}/{$LOOP_TOTAL} : {$ID} {$TITLE}
  • +
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • {/loop} {elseloop rel="catloopwithpagination1000"} @@ -133,7 +114,7 @@ An image from asset directory :

    PAGE {$current_page} :

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

    page choice